BMON

Android support和Androidx库不能共存问题

2021-07-18  本文已影响0人  珹_

做为一个小白开发者 肯定会有其他小白开发者的朋友
今天就有一个朋友问了我这么一个问题
给我发的截图 上面显示 以下报错
我觉得问题不分低级高级 有问题就解决问题

Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
     Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
     Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
     Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
     Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
     Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
     Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
     Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
     Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)
     Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.1.1-runtime (com.android.support:support-compat:27.1.1)

日志中显示什么什么重复等
这一看就是因为Android support和Androidx库不能共存引起的编译报错。因为项目里的其他库已经使用了Androidx库,但是还有应用Android support库,从而引起的冲突
不难解决 只需要在gradle.properties中添加如下

android.useAndroidX=true
android.enableJetifier=true

希望这篇文章能帮助到你

上一篇下一篇

猜你喜欢

热点阅读