這篇文章主要介紹Android Studio3.0升級后使用注意事項有哪些,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
Gradle plugin最高版本4.*
老的項目在使用新版本時,可能會出現gradle plugin沖突的問題
Error:Failed to open zip file. Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network) Re-download dependencies and sync project (requires network)
解決方法:
去往gradle安裝目錄(File->Other Settings->Default Settings,然后可以搜索gradle,右側有Service directory path可以看到你gradle目錄),.gradle\wrapper\dists目錄下找到和項目的gradle-wrapper.properties里版本號一致的文件(比如gradle-3.3-all)刪除,重新編譯即可
Cannot choose between the following configurations,產生這個問題的原因是項目用引用了其他項目,比如compileproject(:library),
解決方法:
Android Studio3.0以后需要使用如下方式:
implementation project(path: ':library', configuration: 'default')
伴隨著 Android Gradle 插件 2.2 版本的發布,近期 android-apt 作者在官網發表聲明證實了后續將不會繼續維護 android-apt,并推薦大家使用 Android 官方插件提供的相同能力。也就是說,大約三年前推出的 android-apt 即將告別開發者,退出歷史舞臺,Android Gradle 插件提供了名為 annotationProcessor的功能來完全代替 android-apt,更換的步驟如下:
移除 Module 的 build.gradle 文件中對 android-apt 的相關配置,也就是刪除類似下面的配置:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'將 Module 的 build.gradle 文件中使用 apt 引入的依賴修改為使用 annotationProcessor 進行引入,修改前配置如下:
dependencies {
compile 'com.google.dagger:dagger:2.0'
apt 'com.google.dagger:dagger-compiler:2.0'
}修改后配置如下:
dependencies {
compile 'com.google.dagger:dagger:2.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
}以上是“Android Studio3.0升級后使用注意事項有哪些”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。