解決Android studio 3.0 apt外掛問題
1.gradle打包,自定義apk名稱程式碼報錯(Cannot set the value of read-only property 'outputFile' )
報錯
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>
解決 :修改檔名程式碼請這樣寫
?1 2 3 4 5 |
android.applicationVariants.all
{ variant ->
variant.outputs.all
{
outputFileName
= "xinlebao_${defaultConfig.versionName}_${releaseTime()}.apk"
}
}
|
2. AAPT2 編譯報錯 AAPT2 error
報錯
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
解決:在gradle.properties中關閉APPT2 編譯
?1 |
android.enableAapt2=false
|
注:如果是eclipse轉到as上的專案,可能沒有gradle.properties檔案,請在專案根目錄中手動建立
3.apt外掛問題(Error:Cannot choose between the following configurations of project :mylibrary:)
報錯:
Error:Cannot choose between the following configurations of project :mylibrary:
- debugApiElements
- debugRuntimeElements
- releaseApiElements
- releaseRuntimeElements
All of them match the consumer attributes:
解決
?1 2 3 4 5 6 7 8 |
//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的依賴,也要這樣更改
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支援指令碼之家。
原文連結:http://www.jianshu.com/p/9af06314e036