记录一下最近一些老项目,从android升级到androidx出现的错误。
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.0-runtime (com.android.support:support-compat:25.3.0)
解决的方案
在根目录的grade.properties添加两行代码。
android.useAndroidX=true
android.enableJetifier=true