Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some file crunching failed, mergeDebugResources FAILED

Tags:

android

This error occurred today after I updated Android Studio from 2.2 to 2.3 , and run app to my phone. Everything was OK last Friday. This Monday gift ruined my all day.
Gradle setting is "Use local gradle distribution", version 3.3 .

log info as below, because it's too long and all of them are similar, I just copied some segments:

Error: Some file crunching failed, see logs for details
:app:mergeDebugResources FAILED
AAPT: \\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-mdpi-v4\abc_btn_switch_to_on_mtrl_00012.9.png ERROR: Unable to open PNG file
AAPT: \\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-xxhdpi-v4\abc_ic_star_half_black_48dp.png ERROR: Unable to open PNG file
AAPT: \\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-hdpi-v4\abc_ic_menu_share_mtrl_alpha.png ERROR: Unable to open PNG file
AAPT: \\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-xxhdpi-v4\abc_text_select_handle_middle_mtrl_light.png ERROR: Unable to open PNG file

AAPT err(Facade for 925134644) : No Delegate set : lost message:\\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-hdpi-v4\abc_ic_star_half_black_48dp.png ERROR: Unable to open PNG file
AAPT err(Facade for 925134644) : No Delegate set : lost message:\\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-mdpi-v4\abc_switch_track_mtrl_alpha.9.png ERROR: Unable to open PNG file

build.gradle as below:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    aaptOptions {
        cruncherEnabled = false
    }

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 18
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            assets.srcDirs = ['src/main/assets', 'src/main/assets/']
        }
    }

    useLibrary 'org.apache.http.legacy'

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:25.2.0'
        compile 'com.android.support:support-v4:25.2.0'
        compile 'com.jakewharton:butterknife:7.0.1'
        compile 'org.jetbrains:annotations-java5:15.0'
    }
}

According to advice from other questions, although some answers are just too outdated, still I have tried following ways, unfortunately, none of them saved me:
1. remove all .9.png files from my project.
2. check all png files are real PNG.
3. insert following settings to build.gradle :

aaptOptions {  
    cruncherEnabled = false  
}  

4. check project file path, not reaching 255 characters (Windows 10).
5. clear gradle caches.
6. Invalidate caches and restart.
7. clean project.

I think log info leads me to files auto-generated by Android Studio. Trying to search error .png files, none of them exists in my project.

Any advice is appreciated.

like image 722
Longer Avatar asked Mar 06 '17 10:03

Longer


1 Answers

problem solved. The solution is here.

Related data as below:
1. According to release notes of Android Studio version 2.3, build cache is enabled by default.
2. so we should disable this setting. Here is official guide, Android Studio/User Guide/build-cache(link https://developer.android.com/studio/build/build-cache.html).
3. go to gradle.properties file, and disable build cache.

// To re-enable the build cache, either delete the following
// line or set the property to 'true'.
android.enableBuildCache=false

the other way is to modify build cache dir by adding

# first line can be skipped because true is the default value by 2.3
android.enableBuildCache=true
android.buildCacheDir =c:\\temp\\
like image 141
Longer Avatar answered Sep 20 '22 03:09

Longer