您好,登錄后才能下訂單哦!
1.現象描述
原來項目在Android studio 2.3一切正常,升級3.0之后報如下錯誤:
Error:Cannot choose between the following configurations of project :android_sdk: - debugApiElements - debugRuntimeElements - releaseApiElements - releaseRuntimeElements All of them match the consumer attributes: - Configuration 'debugApiElements': - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required. - Configuration 'debugRuntimeElements': - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required. - Configuration 'releaseApiElements': - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required. - Configuration 'releaseRuntimeElements': - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.
2.解決辦法:
project的build.gradle文件中刪除
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
module的build.gradle文件中刪除
apply plugin: 'com.neenbedankt.android-apt'
module的build.gradle文件中替換
//apt 'com.jakewharton:butterknife-compiler:8.0.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'
ps:下面再給大家補充介紹android studio更新到3.0后,不支持apt問題
android studio更新到3.0后,不支持apt了,適配僅需要修改以下兩點:
1.移除module目錄下的build.gradle中的 apply plugin: 'android-apt'
2.將apt改成annotationProcessor
例如:
apt 'com.google.dagger:dagger-compiler:2.0.2'
改成
annotationProcessor 'com.google.dagger:dagger-compiler:2.0.2'
總結
以上所述是小編給大家介紹的解決Android studio 2.3升級到Android studio 3.0 后apt報錯問題,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對億速云網站的支持!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。