关于 Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2

最近更新了as3.0.1,前两天跑着还没问题,结果昨晚周末,打开跑不起来了,啊,简直要爆炸,莫名的烦躁。今早到公司,赶紧看下,怎么办呢,还是看看报错问题吧

先来看下错误类型,

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

关于 Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2_第1张图片

关于com.android.tools.aapt2.Aapt2Exception

查看Gradle Console,具体问题,

:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources
C:\Users\????\.gradle\caches\transforms-1\files-1.1\mediarouter-v7-25.2.0.aar\c37b48d162b19cf46019e4dc867080df\res\drawable-xxhdpi-v4\ic_mr_button_connecting_07_dark.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\play-services-base-10.2.6.aar\19c1a94bbad891add3a29179e43dacd0\res\drawable-mdpi-v4\common_google_signin_btn_text_dark_normal_background.9.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a1befe9fac8729a11720f98053ac7774\res\drawable-hdpi-v4\abc_ic_menu_share_mtrl_alpha.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\play-services-cast-framework-10.2.6.aar\d51fcf77a04d548c226725057b00f2ed\res\drawable-mdpi-v4\quantum_ic_skip_next_white_36.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a1befe9fac8729a11720f98053ac7774\res\drawable-xhdpi-v4\abc_text_select_handle_middle_mtrl_light.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a1befe9fac8729a11720f98053ac7774\res\drawable-xhdpi-v4\abc_list_selector_disabled_holo_dark.9.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a1befe9fac8729a11720f98053ac7774\res\drawable-xhdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\mediarouter-v7-25.2.0.aar\c37b48d162b19cf46019e4dc867080df\res\drawable-xxhdpi-v4\ic_vol_type_speaker_dark.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\play-services-cast-framework-10.2.6.aar\d51fcf77a04d548c226725057b00f2ed\res\drawable\cast_mini_controller_progress_drawable.xml: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\jiaozivideoplayer-6.1.2.aar\f1d5cd7b2f28df282bc221417ef8191c\res\layout\jz_layout_standard.xml: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\play-services-cast-framework-10.2.6.aar\d51fcf77a04d548c226725057b00f2ed\res\drawable-xhdpi-v4\quantum_ic_forward_30_grey600_36.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a1befe9fac8729a11720f98053ac7774\res\color\abc_primary_text_material_light.xml: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\play-services-cast-framework-10.2.6.aar\d51fcf77a04d548c226725057b00f2ed\res\drawable-mdpi-v4\quantum_ic_skip_next_white_24.png: error: file not found.
C:\Users\????\.gradle\caches\transforms-1\files-1.1\mediarouter-v7-25.2.0.aar\c37b48d162b19cf46019e4dc867080df\res\drawable-xhdpi-v4\ic_mr_button_connected_19_dark.png: error: file not found.

//后面还有一大堆,类似上面的信息

仔细阅读上面的内容,发现是用户组问题,因为我当前使用用户,叫“工作”,谁起的这个名啊,对开发人员来说,中文路径太多坑了…于是上网看下这个问题,解决办法很简单。
就是在项目的GradleScripts中,gradle.properties文件中添加一行代码就行,即gradle.properties(Project properties)

android.enableAapt2=false

添加后,如图:
关于 Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2_第2张图片

关于找不到gradle.properties文件问题

然而,去找gradle.properties这个文件,发现没有这个文件。因为这是老项目,原来是Eclipse环境开发的,与as创建的项目相比,有些东西会缺失。
怎么办呢,后来想,既然老项目没有,新项目会有,不妨创建一个新的项目,把gradle.properties拷贝到Gradle Scripts中。好吧,
创建项目,拷贝gradle.properties,结果,还是无法编译通过

关于明明有gradle.properties文件,一直编译,但还是出现的错误

这下好了,gradle.properties文件有了,还是不能编译通过。于是,把已有的gradle.properties文件删除,找到项目的源码目录,在此目录下,将拷贝后的gradle.properties粘贴
完成后,如图:
关于 Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2_第3张图片

重新开启as,终于有了,编译通过

你可能感兴趣的:(Android,studio使用,Aapt2Exception,Aapt2Exception)