Search code examples
javaandroidandroid-studioandroid-gradle-pluginnine-patch

Error on nine patch image: Some file crunching failed, see logs for details


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.


Solution

  • 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