android studio 3.0 升級(jí) 項(xiàng)目遇到的問題及更改思路(問題小結(jié))
Android Studio從3.0版本新增了許多功能,當(dāng)然首當(dāng)其沖就是從3.0版本新增了對(duì) Kotlin 開發(fā)語言的支持,除此之外還有其他一些新功能,例如:Android Profiler (其中包含了: CPU Profiler、Memory Profiler、Network Profiler ),APK Debugger,Device File Explorer,Java 8 Language Features等。

android studio 3.0版本升級(jí)問題修改:
===》 問題一
Error:Cannot choose between the following configurations of project :pickerview: - 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.
===》解決方法:
Warning:android-apt plugin is incompatible with future version of Android Gradle plugin. Please use ‘a(chǎn)nnotationProcessor' configuration instead.
原因:更新Android studio 原來項(xiàng)目出現(xiàn)問題。
分析: 尤其是采用butterknife工具的,采用新的Android Studio都會(huì)出現(xiàn)這樣的問題,本人根據(jù)提示最后猜測(cè)原因可能是Android studio更新,然后gradle更新了,這樣的話可能使原來的android-apt 工具跟不上節(jié)奏了,所以讓采用annotationProcessor工具。
解決: 把project下的build.gradle 當(dāng)中的依賴
修改成如下:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:2.4.0-alpha7'
//classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8' //注釋掉
}
}
然后再把module下的build.gradle :
修改如下:
dependencies {
compile project(‘:roadvance-sdk')
compile ‘com.google.dagger:dagger:2.10'
//apt ‘com.google.dagger:dagger-compiler:2.10'
annotationProcessor ‘com.google.dagger:dagger-compiler:2.10'
compile ‘com.android.support:appcompat-v7:25.3.1'
compile ‘com.jakewharton:butterknife:8.5.1'
//apt ‘com.jakewharton:butterknife-compiler:8.5.1'
annotationProcessor ‘com.jakewharton:butterknife-compiler:8.5.1'
}
再把 apply plugin: ‘com.neenbedankt.android-apt ' 這個(gè)引用給刪除。
重新reBuild的一下
===》 問題二
Error:Execution failed for task ':wigetlib:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.1)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
解決方法:
在app的build中
android {
...
defaultConfig {
...
//添加如下配置就OK了
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
...
}
...
}
=====》 問題三
Information:Gradle tasks [:pickerview:generateDebugSources, :pickerview:generateDebugAndroidTestSources, :pickerview:mockableAndroidJar, :zhxflib:generateDebugSources, :zhxflib:generateDebugAndroidTestSources, :zhxflib:mockableAndroidJar, :wigetlib:generateDebugSources, :wigetlib:generateDebugAndroidTestSources, :wigetlib:mockableAndroidJar, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
D:\zhihuixinfanWorkerSpace\ZhiHuiXinFan\app\build\intermediates\manifests\full\debug\AndroidManifest.xml
Error:(12) error: unknown element <uses-library> found.
Error:(12) unknown element <uses-library> found.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 8s
Information:6 errors
Information:0 warnings
Information:See complete output in console
解決方法:
在項(xiàng)目的gradle.properties中:
android.enableAapt2=false
修改了以上問題,我的項(xiàng)目可以正常運(yùn)行了?。?!
總結(jié)
以上所述是小編給大家介紹的android studio 3.0 升級(jí) 項(xiàng)目遇到的問題及更改思路(問題小結(jié)),希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Android自定義動(dòng)畫根據(jù)控件Y軸旋轉(zhuǎn)動(dòng)畫(仿紅包)
這篇文章主要介紹了Android自定義動(dòng)畫根據(jù)控件Y軸旋轉(zhuǎn)動(dòng)畫(仿紅包),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-06-06
實(shí)現(xiàn)輪轉(zhuǎn)廣告帶底部指示的自定義ViewPager控件
在項(xiàng)目中經(jīng)常需要使用輪轉(zhuǎn)廣告的效果,在android-v4版本中提供的ViewPager是一個(gè)很好的工具,而一般我們使用Viewpager的時(shí)候,都會(huì)選擇在底部有一排指示物指示當(dāng)前顯示的是哪一個(gè)page,下面我們就做這個(gè)功能的實(shí)現(xiàn)2013-11-11
Android中程序的停止?fàn)顟B(tài)詳細(xì)介紹
這篇文章主要介紹了Android中程序的停止?fàn)顟B(tài)詳細(xì)介紹,本文講解了什么是程序的停止?fàn)顟B(tài)、為什么Android要引入這一狀態(tài)、激活狀態(tài)和停止?fàn)顟B(tài)的切換、如何變?yōu)橥V範(fàn)顟B(tài)等內(nèi)容,需要的朋友可以參考下2015-01-01
玩轉(zhuǎn)Kotlin 徹底弄懂Lambda和高階函數(shù)
這篇文章主要幫助大家徹底弄懂Lambda和高階函數(shù),玩轉(zhuǎn)Kotlin,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10
Jetpack?Compose實(shí)現(xiàn)點(diǎn)擊事件click的多種方法
這篇文章主要介紹了Jetpack?Compose實(shí)現(xiàn)點(diǎn)擊事件的多種方法,Jetpack?Compose是一款基于Kotlin的聲明式UI工具包,可以方便地創(chuàng)建漂亮的用戶界面,下面我們就來看看Jetpack?Compose添加點(diǎn)擊事件都可以怎么實(shí)現(xiàn)2024-02-02
Android TimerTask 的簡單應(yīng)用及注意事項(xiàng)
這篇文章主要介紹了Android TimerTask 的簡單應(yīng)用及注意事項(xiàng)的相關(guān)資料,需要的朋友可以參考下2017-06-06

