AAPTerr: No Delegate set : lost message:\\?\C:\...\build-cache\...\*.png ERROR: Unable to open PNG f

AAPT: \\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-xhdpi-v4\abc_list_pressed_holo_light.9.png ERROR: Unable to open PNG file
AAPT: \\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-hdpi-v4\abc_ic_star_half_black_48dp.png ERROR: Unable to open PNG file
AAPT: \\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-mdpi-v4\abc_btn_switch_to_on_mtrl_00012.9.png ERROR: Unable to open PNG file
.
.
.
AAPT err(Facade for 1178074264) : No Delegate set : lost message:\\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-mdpi-v4\abc_ic_menu_cut_mtrl_alpha.png ERROR: Unable to open PNG file
AAPT err(Facade for 1178074264) : No Delegate set : lost message:\\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-hdpi-v4\notification_bg_normal_pressed.9.png ERROR: Unable to open PNG file
AAPT err(Facade for 1178074264) : No Delegate set : lost message:\\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-hdpi-v4\abc_list_pressed_holo_dark.9.png ERROR: Unable to open PNG file
.
.
.
FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':Volley:mergeDebugAndroidTestResources'.
> Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: 

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':agora:mergeDebugAndroidTestResources'.
> Error: Some file crunching failed, see logs for details

Android Studio 从2.2升级到2.3后,因为svn地址迁移所以重新导入项目,发现报了如上的错误。
进入到报错的目录可以发现这些.9的图片都是存在且是正常的.9图片;而且这些图片并不是我倒入进去的,而是V7或引用其他的库编译时自动生成的。
试了百度里面很多办法都没能解决,最后在伟大的stackoverflow上面找到了解决方案,在文末附上链接。下面记录下尝试过的办法(stackoverflow也有写):
1. 排查是否有不合格的.9图片。(实际上报错图片不是手动引入的)
2. 检查png图片是否合格。(比如由jpg直接改后缀的,而不是导出的)
3. 在build.gradle加入设置:

aaptOptions {
    cruncherEnabled = false
    useNewCruncher=false
}

4. 清除报错路径缓存
5. clean或者rebuild项目

以上的方法都不能解决这个问题,下面说下stackoverflow上的解决办法:
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(linkhttps://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\

翻译过来就是:
1. 根据Android Studio版本2.3的发行说明,默认情况下启用构建缓存。
2. 所以我们应该禁用这个设置。这是官方指南,Android Studio/User Guide/build-cache(链接https://developer.android.com/studio/build/build-cache.html)。
3. 打开gradle.properties文件,并禁用构建缓存。
android.enableBuildCache=false
另一种方法是通过添加以下代码来修改构建缓存目录
//first line can be skipped because true is the default value by 2.3
android.enableBuildCache=true
android.buildCacheDir =c:\temp\

以上问题解决,可以通过编译。
Stackoverflow问题地址:
http://stackoverflow.com/questions/42622654/some-file-crunching-failed-mergedebugresources-failed

你可能感兴趣的:(Android)