詳解升級(jí)Android Studio3.0時(shí)遇到的幾個(gè)問題
今天收到了Android Studio3.0更新推送,在升級(jí)過程中遇到幾個(gè)問題,在這里把問題和解決方法記錄下,方便要升級(jí)的童鞋。如果還有童鞋遇到不同的問題,也可以評(píng)論下我做下記錄
1.gradle打包,自定義apk名稱代碼報(bào)錯(cuò)(Cannot set the value of read-only property 'outputFile' )
報(bào)錯(cuò)
Error:(56, 0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
<a href="openFile:D:\eclipseCode\ipay-android\xinlebao\build.gradle" rel="external nofollow" >Open File</a>
解決 :修改文件名代碼請(qǐng)這樣寫
android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "xinlebao_${defaultConfig.versionName}_${releaseTime()}.apk" } }
2. AAPT2 編譯報(bào)錯(cuò) AAPT2 error
報(bào)錯(cuò)
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
解決:在gradle.properties中關(guān)閉APPT2 編譯
android.enableAapt2=false
注:如果是eclipse轉(zhuǎn)到as上的項(xiàng)目,可能沒有g(shù)radle.properties文件,請(qǐng)?jiān)陧?xiàng)目根目錄中手動(dòng)創(chuàng)建
3.apt插件問題(Error:Cannot choose between the following configurations of project :mylibrary:)
報(bào)錯(cuò):
Error:Cannot choose between the following configurations of project :mylibrary:
- debugApiElements
- debugRuntimeElements
- releaseApiElements
- releaseRuntimeElements
All of them match the consumer attributes:
解決
//1.在project的build.gradle中刪除 classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' //2.在module的build.gradle中刪除 apply plugin: 'android-apt' //3.將module的build.gradle文件中的dependency apt 'com.jakewharton:butterknife-compiler:8.1.0' //改為 annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
其他使用apt的依賴,也要這樣更改
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
使用Android Studio創(chuàng)建OpenCV4.1.0 項(xiàng)目的步驟
這篇文章主要介紹了使用Android Studio創(chuàng)建OpenCV4.1.0 項(xiàng)目的步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10Android獲取應(yīng)用程序名稱(ApplicationName)示例
本文以實(shí)例方式為大家介紹下獲取應(yīng)用程序名稱(ApplicationName)的具體實(shí)現(xiàn),感興趣的各位可以參考下哈2013-06-06Android上使用ZXing識(shí)別條形碼與二維碼的方法
這篇文章主要介紹了Android上使用ZXing識(shí)別條形碼與二維碼的方法,需要的朋友可以參考下2014-08-08Android事件分發(fā)機(jī)制深入刨析原理及源碼
Android?的事件分發(fā)機(jī)制大體可以分為三部分:事件生產(chǎn)、事件分發(fā)?、事件消費(fèi)。事件的生產(chǎn)是由用戶點(diǎn)擊屏幕產(chǎn)生,我們這次著重分析事件的分發(fā)和消費(fèi),因?yàn)槭录职l(fā)和處理聯(lián)系的過于緊密,這篇文章將把事件的分發(fā)和消費(fèi)放在一起分析2023-04-04