1

I cannot add a ninepatch png to my project because of this build error:

Information:Gradle tasks [:app:assembleDebug] Error:Some file crunching failed, see logs for details Error:Execution failed for task ':app:mergeDebugResources'.

Error: Some file crunching failed, see logs for details Information:BUILD FAILED Information:Total time: 11.955 secs Information:2 errors Information:0 warnings Information:See complete output in console

Fact: I have already added one which runs perfectly, the other one is made with the very same methodology, same boundaries and stuff yet makes build error.

I have tried:

  • Clean
  • Rebuild project
  • Restart AS
  • Restart PC
  • Made nine patch with Photoshop
  • Made nine patch with AS built in nine patch maker
  • Various naming conventions
  • Shorten the dir path of the project
  • Adding crunch: false to gradle

Extra wtf:

  • If i just copy the pixel contents of the not working nine patch to the working one the error appears.

Also, the error says "see logs"

Where are the logs???

Because its not in logcat thats for sure.

Please help if you can. This drives me nuts. Im really interested why I have to spend half a day with an image import.

Farhad
  • 12,178
  • 5
  • 32
  • 60
Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222
  • do you have the 9patch and without 9patch image both in the resources ? also have you tried removing .9 from the 9patch image and tried naming it .png ? – Ankit Arora Jun 18 '17 at 18:14
  • https://stackoverflow.com/a/4280451/3270494 have you tried this ? "The resource compiler strips 9-patches one-pixel borders away (and presumably stores the information gained from them in a more efficient way outside of the .9.png file). If you've fished these .9.png files out of an .apk, you'll need to add the border back by hand." – Ankit Arora Jun 18 '17 at 18:27
  • It's certainly not logcat, because that's show run-time errors & info of your phone while your problem is a build time problem if I understand correctly. Keep searching for build-time log files. – Csaba Toth Jun 18 '17 at 18:34
  • `Where are the logs???` Perform `./gradlew --debug assembleDebug` – azizbekian Jun 19 '17 at 08:11
  • @AdamVarhegi put the image in drawable folder try clean project ....whats the extension of your image? – PN10 Jun 19 '17 at 10:24

5 Answers5

6

I have collected some sollutions. Please check one by one. Hope it may help you.

Suggestion#1:

This is caused by the path length restriction. I think it's 256 characters maximum.

Relocate your project and the build will succeed.

Resource Link: https://stackoverflow.com/a/25209204

Suggestion#2:

Sometimes .9.png images are corrupted. So you can replace it in your drawables directory.

Resource Link: https://stackoverflow.com/a/41380118

Suggestion#3:

Best solution is changing the buildDir in build.gradle:

For example:

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

Rebuild and happy coding.

Resource Link: https://stackoverflow.com/a/41877283

Suggestion#4:

You can diagonse by the following command:

./gradlew :app:mergeIntegrationDebugResources --debug > buildLog.txt

Once that finished, Open the buildLog.txt file, and searched for "Error" (no quotes in actual search). Then you will find those files are having problems, and then removed it from the appropriate folder, and then re-run the command above until you didn't get any errors.

Resource Link: https://stackoverflow.com/a/36648743

Suggestion#5:

file >> invalidate caches/restart

Suggestion#6:

  1. Go to your build.gradle file in your project.
  2. Change:
dependencies {
    classpath 'com.android.tools.build:gradle:1.1.0'

to:

dependencies {
    classpath 'com.android.tools.build:gradle:1.1.3'

same problem is also coming in 'com.android.tools.build:gradle:1.5.0'. On that case downgrade it.

  1. Then Clean --> Rebuild

Resource Link: https://stackoverflow.com/a/31638208

Suggestion#7:

for anyone having the same problem. this solved the issue for me:

"aapt" IOException error=2, No such file or directory" why can't I build my gradle on jenkins?

It's an issue with 64-bit OS, because aapt isn't available you have to install these 2 packages:

sudo apt-get install lib32stdc++6 lib32z1

Resource Link: https://github.com/facebook/react-native/issues/7320

SkyWalker
  • 28,384
  • 14
  • 74
  • 132
  • 1
    allprojects { buildDir = "C:/tmp/${rootProject.name}/${project.name}" repositories { jcenter() } } this is working for me Thank you so much – Prateek Sharma Nov 21 '17 at 15:10
2

Try adding this to your app build.gradle file

 android {
    aaptOptions {  
                cruncherEnabled = false  
            } 
        }
Farhad
  • 12,178
  • 5
  • 32
  • 60
1

I had the same problem, deleting the right and the bottom borders of the 9-patch png file fixed the problem.

M. Chavoshi
  • 1,023
  • 9
  • 17
0

I had similar problem , The Log was shown in Gradle Console for me . The problem for me was that the nine patch image was wrong, it had 2 vertical paddings at right . I removed 1 vertical padding and it worked fine.

Manohar
  • 22,116
  • 9
  • 108
  • 144
0

I had same problem. Errorenous 9patch was forgotten into mipmap folder..