升级androidx 报错bug

2022-04-01  本文已影响0人  cain07

1.Android Studio:引入androidx

1、在项目的 gradle.properties 文件中配置如下

# 启用Androidx生成支持的标志
android.useAndroidX=true
# 启用Maven库转换的标志
android.enableJetifier=true

2、引入

  implementation 'androidx.appcompat:appcompat:1.2.0'

2. Android Studio 引入 androidx 工具

https://blog.csdn.net/qq_24382363/article/details/87285438

3. 报错

版本编译时出现下面问题:Error:(3575) Multiple substitutions specified in non-positional format; did you mean to add the formatted=”false” attribute?

这时候会提示上述错误,因为sdk采用了更加严格的aapt编译,正确的用法如下

如果字符串含有%,而不需要格式化可以有三种方法解决

加上formatted="false"
<string name="time_picker" formatted="false">%s时</string>
用两个%%
<string name="time_picker">%%s时</string>
用转义字符\
<string name="time_picker" >\%s时</string>

4. 报错

AAPT: error: duplicate value for resource 'attr/itemIconTint' with config ''.
AAPT: error: resource previously defined here.

这个错误是引用的两个包中的属性名称冲突导致
忽略已存在的框架

implementation('com.github.bumptech.glide:glide:4.9.0') {
        exclude group: "com.android.support"
    }
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

jar 包

   implementation ('com.google.android.gms:play-services-appindexing:9.8.0'){
        exclude group: "com.android.support"//去掉glide中的support包
    }

aar

implementation(name: '×××××××aar包', ext: 'aar') {
 exclude module: 'gson'
 }

但是 并不确定 是 有这个 冲突的库

那 直接 去aar 中删除itemIconTint

解压aar文件到tmpDir目录下

unzip ×××.aar -d tmpDir

修改后 将tmpDir重新打包成一个新的aar

jar cvf ×××NewLib.aar -C tmpDir/ .

Android修改第三方.aar后重新打包

https://www.jianshu.com/p/f0a267551493

上一篇 下一篇

猜你喜欢

热点阅读