1

I have many 9patch png files that worked fine in Eclipse IDE, but when I try using them in Android studio, I get the error:

> Error: Some file crunching failed, see logs for details

I have tried disabling the cruncher in many ways, but none of them works. How can I successfully disable cruncher in Android studio?

Here is my current graddle configuration which still does not disable the cruncher.

android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
enforceUniquePackageName = false
useLibrary 'org.apache.http.legacy'

if (project.hasProperty('devBuild')) {
    aaptOptions.cruncherEnabled = false
}

lintOptions {
    disable "ResourceType"
}

defaultConfig {
    applicationId "com.ducky.learnstation"
    minSdkVersion 16
    targetSdkVersion 18
    multiDexEnabled true
    aaptOptions.setProperty("cruncherEnabled", false);
}


packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}

aaptOptions {
    cruncherEnabled = false
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

}

kc ochibili
  • 3,103
  • 2
  • 25
  • 25
  • Possible duplicate of [Disable Android resource / image / png optimization](https://stackoverflow.com/questions/12929884/disable-android-resource-image-png-optimization) – Abhinav Saxena Jun 29 '17 at 06:38
  • @AbhinavSaxena my question is about 9 patch images. not regular png images. The solution in the link you provided only works on png images. it does not work on .9.png images. – kc ochibili Jun 30 '17 at 06:00
  • Yes, excuse me for that, the crunching error only comes for 9 patch images as far as I know. Please see the depth of the path of your project is not too deep! – Abhinav Saxena Jun 30 '17 at 08:39
  • Any success? Can you move your project to the root and try that again? Also 9 patch images are not meant to be too large in resolution. They are short sized because they have portions that stretch. – Abhinav Saxena Jul 04 '17 at 04:52
  • did you find a solution? I'm facing the same issue with 9 patch images working on eclipse but not on Android Studio (I'm migrating an old project). Any help would be appreciated – giroxiii Jul 25 '17 at 11:48
  • 1
    @AbhinavSaxena I didn't succeed in disabling cruncher on my 9patch images. But it seemed like updating my build tools helped. – kc ochibili Jul 25 '17 at 18:29
  • @giroxii I removed the .9 in the image file name. It worked for some of the 9 patch images, while I lost the stretch effect for others. For those I lost the stretch effect, I retained the .9 in the image name then opened the image in android studio's 9patch editor, click show bad patches, then to fix it you need to click the side of the rectangle that has no black dot or line. I updated the my build tools to the latest version, set my project to use that latest version. (<- do this first before my other suggestions) – kc ochibili Jul 25 '17 at 18:29

1 Answers1

0

Apart from the answers: Disable Android resource / image / png optimization

The common cause of the crunching not working is that your project path is too deep in the file system.

driveletter:/level1/level2/level3/level4/level5/ProjectFolder

Also 9 patch images are not meant to be too large in resolution. They are short sized because they have portions that stretch. Inspect to see whether the 9 patch image is good or not.

Also if the error is for regular images that come from support library, then updating build tools is a must.

Abhinav Saxena
  • 1,990
  • 2
  • 24
  • 55
  • Thank you for the pointer on another potential cause, but the gradle error I got was specific, and it pointed to my 9 patch images. The solution in the link you provided only works for regular png images. – kc ochibili Jun 30 '17 at 06:03