生命不息 折騰不止
上了Canary版本之后,隨即升級了gradle plugin. 從此開啟蛋疼的錯誤之路
首先 AAPT2 compile failed
我們的項目需要使用統(tǒng)一定義的控件資源,但是Android Studio 直接在編譯的時候就彈出AAPT2 compile failed ,各種
invalid dimen.
stackoverflow上面的解釋說要配置en環(huán)境https://stackoverflow.com/questions/44196672/aapt2-compile-failed-invalid-dimen-on-android-3-0-canary-1.
但是我一直沒配置好,不知道是什么鬼原理,然后我反了Google的更新日志,發(fā)現(xiàn)了最下面有一行話.
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
網(wǎng)上搜索穷遂,原來是此版本引入的 bug厕倍。開啟 Gradle 的守護進程后就會導致此問題蛔六,重啟 Android Studio 無效餐曹。
解決方案一:
命令行進入工程根目錄迟几,執(zhí)行 ./gradlew --stop(Windows 版 gradlew --stop)
修改工程中 gradle.properties 文件 org.gradle.configureondemand=false
Android Studio 菜單欄 File->Invalide Caches / Restart...
解決方案二:
回退到 Canary 4 或以前的版本。
PS:官方回復說在下一個 Canary 版本中修復了此問題酿箭。