Android Studio 3.0 Canary 出现的编译错误 AAPT2 compile failed

生命不息 折腾不止

上了Canary版本之后,随即升级了gradle plugin. 从此开启蛋疼的错误之路

首先 AAPT2 compile failed

我们的项目需要使用统一定义的控件资源,但是Android Studio 直接在编译的时候就弹出AAPT2 compile failed ,各种
invalid dimen.
stackoverflow上面的解释说要配置en环境https://stackoverflow.com/questions/44196672/aapt2-compile-failed-invalid-dimen-on-android-3-0-canary-1.
但是我一直没配置好,不知道是什么鬼原理,然后我反了Google的更新日志,发现了最下面有一行话.
https://androidstudio.googleblog.com/2017/06/android-studio-30-canary-5-is-now.html

AAPT2. We are continuing to stabilize AAPT2 which enables incremental resource processing. If your build fails due to resource processing issue, please send us a bug report. To temporarily disable AAPT, set android.enableAapt2=false in your gradle.properties file.

直接在gradle.properties 中设置android.enableAapt2=false,问题解决.

再来,Canary 5 不停的报
Failed to apply plugin Android Gradle plugin 3.0.0-alpha5 must not be applied to project

蒙蔽脸.jpg

网上搜索,原来是此版本引入的 bug。开启 Gradle 的守护进程后就会导致此问题,重启 Android Studio 无效。

解决方案一:

命令行进入工程根目录,执行 ./gradlew --stop(Windows 版 gradlew --stop)
修改工程中 gradle.properties 文件 org.gradle.configureondemand=false
Android Studio 菜单栏 File->Invalide Caches / Restart...
解决方案二:

回退到 Canary 4 或以前的版本。

PS:官方回复说在下一个 Canary 版本中修复了此问题。

你可能感兴趣的:(Android Studio 3.0 Canary 出现的编译错误 AAPT2 compile failed)