gradle 使用 exclude 解决jar包冲突
1. 查看冲突的jar包;一眼能看出来的跳到第二步; 遇到隐藏比较深的就比较难受了,肉眼完全看不出来,此时使用以下命令查看:gradlew -q app:dependencies 查看依赖树;比如:Duplicate class androidx.dynamicanimation.animation.DynamicAnimation$OnAnimationUpdateListener found
1. 查看冲突的jar包;一眼能看出来的跳到第二步; 遇到隐藏比较深的就比较难受了,肉眼完全看不出来,此时使用以下命令查看:
gradlew -q app:dependencies 查看依赖树;
比如:
Duplicate class androidx.dynamicanimation.animation.DynamicAnimation$OnAnimationUpdateListener found in modules classes.jar (androidx.dynamicanimation:dynamicanimation:1.0.0) and classes.jar (dynamicanimation-1.1.0-alpha04.aar)
Duplicate class androidx.dynamicanimation.animation.DynamicAnimation$ViewProperty found in modules classes.jar (androidx.dynamicanimation:dynamicanimation:1.0.0) and classes.jar (dynamicanimation-1.1.0-alpha04.aar)
gradlew -q app:dependencies:
。。。
+--- com.airbnb.android:lottie:3.3.1
| +--- androidx.appcompat:appcompat:1.0.0 -> 1.3.0-rc01 (*)
| \--- com.squareup.okio:okio:1.17.4
+--- com.google.android.material:material:1.3.0
| +--- androidx.annotation:annotation:1.0.1 -> 1.2.0
| +--- androidx.appcompat:appcompat:1.1.0 -> 1.3.0-rc01 (*)
| +--- androidx.cardview:cardview:1.0.0
| | \--- androidx.annotation:annotation:1.0.0 -> 1.2.0
| +--- androidx.coordinatorlayout:coordinatorlayout:1.1.0 (*)
| +--- androidx.constraintlayout:constraintlayout:2.0.1 -> 2.1.0-beta01 (*)
| +--- androidx.core:core:1.2.0 -> 1.6.0-alpha01 (*)
| +--- androidx.dynamicanimation:dynamicanimation:1.0.0
| | +--- androidx.core:core:1.0.0 -> 1.6.0-alpha01 (*)
| | +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
| | \--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
| +--- androidx.annotation:annotation-experimental:1.0.0
| +--- androidx.fragment:fragment:1.0.0 -> 1.3.2 (*)
| +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.3.1 (*)
| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.0-rc01 (*)
右键find, 找到dynamicanimation:dynamicanimation,可以看到com.google.android.material:material:1.3.0 引入了它;
2.使用exclude过滤掉;
implementation ('com.google.android.material:material:1.3.0') {
exclude group: "androidx.dynamicanimation", module: "dynamicanimation"
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)