Failed to hash files, mergeDebugResources FAILED

This error occurred today after I updated Android Studio from 2.2 to 2.3 and launched the application on my phone. Last Friday, everything was in order. This Monday gift ruined me all day.
Gradle option "Use local gradle distribution", version 3.3.

the log information is as below because it is too long and they are all alike, 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 shown 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 the advice of other questions, although some answers are too outdated, I still tried the following methods, unfortunately, none of them saved me:
1. Remove all .9.png files from my project.
2. check that all png files are real PNG.
3. Paste the following settings for build.gradle:

 aaptOptions { cruncherEnabled = false } 

4. Check the path to the project file, not up to 255 characters (Windows 10).
5. Clear gradle caches.
6. Invalid caches and restarts.
7. clean design.

I think the log information leads me to files automatically created by Android Studio. Trying to search for .png error files, none of them exist in my project.

Any advice is appreciated.

+5
source share
2 answers

the problem is resolved. The solution is here .

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

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

another way is to change the built-in cache by adding

 # first line can be skipped because true is the default value by 2.3 android.enableBuildCache=true android.buildCacheDir =c:\\temp\\ 
+8
source

This causes this error because in your pullout you need to change the extension to .png from another format. I would recommend changing the extension using the MS mask or another image editing application such as Gimp.

0
source

Source: https://habr.com/ru/post/1265085/


All Articles