[android] ‘app : mergeDebugResources’작업 실행 실패 크 런처 크 런처… png 실패

* .png 형식의 그림을 drawable-directory에 추가하고 레이아웃과 연결했습니다. 하지만 빌드하려고 할 때마다 오류가 나타납니다.

“… Crunching Crunsher … png 실패”

다음은 콘솔의 출력입니다.

app:mergeDebugResources
AAPT out(1561599) : No Delegate set : lost message:Done
AAPT out(12956469) : No Delegate set : lost message:Done
AAPT out(20612543) : No Delegate set : lost message:Crunching             C:\Dev\StudioProjects\test\android\app\src\main\res\drawable\bt_meeting_focused.png
AAPT out(11030156) : No Delegate set : lost message:Crunching     C:\Dev\StudioProjects\test\android\app\src\main\res\mipmap-mdpi\ic_launcher.png
AAPT out(11030156) : No Delegate set : lost message:Crunching single PNG file: C:\Dev\StudioProjects\test\android\app\src\main\res\mipmap-    mdpi\ic_launcher.png
AAPT out(11030156) : No Delegate set : lost message:    Output file:     C:\Dev\StudioProjects\test\android\app\build\intermediates\res\debug\mipmap-mdpi-v4\ic_launcher.png
AAPT out(11030156) : No Delegate set : lost message:Done
AAPT err(11030156): libpng error: Not a PNG file
AAPT out(20612543) : No Delegate set : lost message:Crunching single PNG     file:     C:\Dev\StudioProjects\test\android\app\src\main\res\drawable\bt_meeting_focused.png
AAPT out(20612543) : No Delegate set : lost message:    Output file:     C:\Dev\StudioProjects\test\android\app\build\intermediates\res\debug\drawable\b    t_meeting_focused.png
AAPT out(20612543) : No Delegate set : lost message:Done
AAPT err(20612543): libpng error: Not a PNG file
AAPT err(1561599): libpng error: Not a PNG file
AAPT err(12956469): libpng error: Not a PNG file

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Crunching Cruncher uhr.png failed, see logs

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --    debug option to get more log output.

BUILD FAILED

Total time: 14.598 secs
Executing tasks: [clean, :app:generateDebugSources,     :app:generateDebugAndroidTestSources]

Configuration on demand is an incubating feature.
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportSupportV42220Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
AAPT out(14080484) : No Delegate set : lost message:Done
AAPT out(9206750) : No Delegate set : lost message:Done
AAPT out(25360025) : No Delegate set : lost message:Done
AAPT err(25360025): libpng error: Not a PNG file
AAPT err(14080484): libpng error: Not a PNG file
AAPT out(6423170) : No Delegate set : lost message:Crunching C:\Dev\StudioProjects\test\android\app\src\main\res\drawable\anfrage_senden_.png
AAPT err(6423170): libpng error: Not a PNG file
AAPT out(6423170) : No Delegate set : lost message:Crunching single PNG file:     C:\Dev\StudioProjects\test\android\app\src\main\res\drawable\anfrage_senden_.png
AAPT out(6423170) : No Delegate set : lost message: Output file: C:\Dev\StudioProjects\test\android\app\build\intermediates\res\debug\drawable\a    nfrage_senden_.png
AAPT out(6423170) : No Delegate set : lost message:Done
AAPT err(9206750): libpng error: Not a PNG file

Process list not empty
:app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Crunching Cruncher uhr.png failed, see logs

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --    debug option to get more log output.

BUILD FAILED

Total time: 4.325 secs

나는 프로젝트를 정리하고, 다시 빌드하고, “gradlew clean build –refresh-dependencies”를 통해 종속성을 새로 고치려고했지만 아무것도 작동하지 않았습니다. build.gradle 파일에서 종속성을 확인했지만 오류가 발생하는 것 같습니다.

   apply plugin: 'com.android.application'
   android {
   compileSdkVersion 22
   buildToolsVersion "22.0.1"
   compileOptions.encoding = 'windows-1251'

   defaultConfig {
       applicationId "com.example.benutzer.test"
       minSdkVersion 16
       targetSdkVersion 22
       versionCode 1
       versionName "1.0"
   }
   buildTypes {
    release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android.txt'),    'proguard-rules.pro'
       }
   }
   }

   dependencies {
   compile 'com.android.support:support-v4:22.2.0'
  }

아이디어가 있습니까? 오류의 원인은 무엇입니까? 파일 경로도 너무 길지 않고 매번 256 개의 기호까지 표시됩니다.

미리 감사드립니다 🙂



답변

제 경우에는 드로어 블 폴더에 추가 한 PNG 파일로 인해 오류가 발생했습니다. 확장자를 jpg 에서 png로 변경했습니다.텍스트를 부적절하게 변경 한 다음 PNG로 업로드 로 변경했습니다.

이것이 Android Studio가 지적한 문제였습니다.

이 문제를 해결하고 Paint.NET 도구 또는 다른 도구 (올바른 방법)를 사용하여 파일 확장자를 변경 한 다음 드로어 블 폴더에 업로드 하여 오류가 사라지는 문제를 해결 했습니다.


답변

프로젝트를 외부 디렉터리로 이동하여이 문제를 해결 한 다음 성공적으로 컴파일했습니다.

프로젝트 디렉토리의 긴 경로 때문이었습니다.

예를 들어 다음에서 프로젝트를 이동했습니다.

D:/Android/Apps/AndroidStudioProject/AppName

D:/Android/AppName


답변

이는 (.jpg)와 같은 일부 확장자를 가진 드로어 블에 이미지를 추가하고이를 .png 형식으로 변경하거나 저장했기 때문입니다 (이 오류는 편집기 도구를 사용하지 않고 이미지 형식을 수동으로 변경하는 동안 발생합니다).

Android Studio는 AAPT (Android Asset Packaging Tool)를 사용하여 리소스 패키지를 컴파일하는 동안 오류가 발생하므로 GIMP 또는 Paint 와 같은 일부 이미지 편집기 도구 를 사용하여 그에 따라 확장 프로그램을 저장하기 만하면됩니다. 모든 것이 완료되면 프로젝트를 다시 빌드하십시오.

예 : 그림판에서 이미지를 엽니 다 (이미지를 끌어서 놓아서 열 수 있음) → 메뉴 파일다른 이름으로 저장파일 형식 → 아래 그림과 같이 드롭 다운에서 필요한 형식을 선택합니다.

여기에 이미지 설명 입력

여기에 이미지 설명 입력


답변

제 경우에는 해결책이 간단했습니다. 전체 프로젝트를 경로가 짧은 다른 위치로 옮겼습니다.

긴 디렉토리 이름과 파일 이름으로 인해 문제가 발생했습니다.


답변

가장 좋은 해결책은 build.gradle 에서 buildDir 을 변경하는 입니다 .

예를 들면 :

allprojects {
    buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    repositories {
        jcenter()
    }
}

재 구축하고 행복한 코딩.


답변

제 경우 에는 동일한 라이브러리의 두 가지 버전을 추가하는 어리석은 실수로 라이브러리 파일변경 하여이 문제를 해결했습니다 .

다양한 이유 때문일 수 있으므로 문제에 따라이 문제를 해결하기 위해 다음과 같은 방법을 찾았습니다.

  1. 자원 불일치

  2. 리소스의 누락 된 속성, 잘못된 태그 등

  3. 스타일 문제

  4. 스타일에 누락 된 이름

  5. 리소스 및 라이브러리의 중복

  6. 때로는 build.gradle에서 호환 가능한 라이브러리를 변경하여 해결할 수도 있습니다.

  7. 실행중인 aapt명령을

  8. 확장자 이름을 .jpg에서 .png로 변경

  9. 간단히 Clean Project.

    1. 어떤 경우에도 Android Studio를 다시 시작하면 문제를 해결할 수 있습니다.

답변

이는 PNG 파일이 지원되지 않거나 파일 이름을 직접 변경했기 때문입니다.

다음 단계를 수행하십시오.

  1. Android Studio에서 데스크톱으로 이미지 소스 파일을 복사합니다.
  2. 그림판으로 파일을 엽니 다.
  3. 확장자 .png로 파일 저장
  4. 복사 한 Android Studio에서 기존 소스 파일을 삭제합니다.
  5. 그림판을 통해 이름을 바꾼 새로 생성 된 파일을 추가합니다.

문제 해결됨 🙂