AS运行出现如下错误:
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.0.1-runtime.jar (androidx.core:core:1.0.1) and support-compat-25.3.1-runtime.jar (com.android.support:support-compat:25.3.1)
可以看到 从androidx.core:core:1.0.1 和 com.android.support:support-compat:25.3.1 两个jar 引入了重复
的类,解决方案 只需要引入其中一个jar包即可。compileOnly
推荐保留androidx库,解决方法如下:
# 需要在gradle.properties中添加下面两行代码
# 选择将 androidX作为您的支持库
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true