1.倉庫地址不支持http
修改前:
maven {
url 'http://maven.aliyun.com/repository/public'
}
修改后:
maven {
allowInsecureProtocol = true
url 'http://maven.aliyun.com/repository/public'
}
2.提示androidX 功能未激活
- This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
項目早就支持了androidx,根目錄下的gradle.properties已經(jīng)有如下兩行
android.useAndroidX=true
android.enableJetifier=true
但是rebuild后依然報上面的錯,找了半天發(fā)現(xiàn)老項目的app的module下也有一個gradle.properties,但是里面的android.useAndroidX=false。。。。。。
醉了醉了,把這個多余的gradle.properties刪掉就好了。
不知道原先的開發(fā)為什么要在app的module下新建gradle.properties,也不知道gradle3.6.x以上的版本為什么用app的module下的gradle.properties
后來在AGP4.2.0更新說明中看到了這么一句話:
gradle.properties 文件的行為變更
從 AGP 4.2 開始,無法再從子項目中替換 Gradle 屬性。也就是說,如果您在子項目(而不是根項目)上的 gradle.properties 文件中聲明某個屬性,該屬性將被忽略。
也就是說4.2之前的某些版本會用module下的gradle.properties替換掉project根目錄下的gradle.properties,4.2之后的不影響
3.編譯時提示資源沖突 Entry name 'xxx' collided
AGP 3.6 以上的版本,在調(diào)試開發(fā)APP的時候采用了新的打包方式,這里關(guān)閉新的打包方式,可以讓編譯通過
android.useNewApkCreator=false
暫時沒有找到更好的辦法,先這么干,如果有大佬找到了更好的辦法,請告訴我
4.升級至4.1.0后,找不到依賴的module中的R文件
android.namespacedRClass 屬性已重命名為 android.nonTransitiveRClass
實驗性標(biāo)記 android.namespacedRClass 已重命名為 android.nonTransitiveRClass。
此標(biāo)記在 gradle.properties 文件中設(shè)置,可啟用每個庫的 R 類的命名空間,以便其 R 類僅包含庫本身中聲明的資源,而不包含庫的依賴項中的任何資源,從而縮減相應(yīng)庫的 R 類大小。
解決辦法:刪除gradle.properties中的android.nonTransitiveRClass=true
5.module中的aar無法引用
報錯信息如下:Direct local .aar file dependencies are not supported when building an AAR.
The resulting AAR would be broken because the classes and Android resources from any local .aar
file dependencies would not be packaged in the resulting AAR. Previous versions of the Android
Gradle Plugin produce broken AARs in this case too (despite not throwing this error).
修改前aar依賴方式:
api(name: 'xxxxx', ext: 'aar')
修改后aar依賴方式:
- project根目錄下新建一個目錄local_aar,拷貝xxxxx.aar到該目錄下
- local_aar目錄下新建一個build.gradle文件,添加以下代碼
configurations.maybeCreate("default")
artifacts.add("default", file('xxxxx.aar'))
- settings.gradle添加local_aar目錄
include(":local_aar")
4.在module中添加對local_aar的依賴
api project(":local_aar")
還有一種方案是將aar發(fā)布到maven進行遠程依賴
可以參考:Direct local .aar file dependencies are not supported
5.Execution failed for task ':minifyPreviewReleaseWithR8'.
[CIRCULAR REFERENCE:com.android.tools.r8.utils.b: Expected [access-flag]* void <init> at C:\Users\DT.gradle\caches\transforms-3\fd8ee676f15f0d57578a9e28a336cbac\transformed\pol
yvPlayer-2.15.2\proguard.txt:95:42
public PolyvAuxiliaryVideoView <init>;
解決辦法: polyvPlayer升級至net.polyv.android:polyvPlayer:2.15.3
6.升級至7.x后出現(xiàn)'元素類型 "uses-sdk" 必須后跟屬性規(guī)范 ">" 或 "/>"
這個問題還未解決,應(yīng)該是某個第三方library中manifest不規(guī)范少寫了尖括號導(dǎo)致的
參考: