本篇文章主要讲解,安卓11项目运行后报错Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.13.0-runtime的主要原因及解决办法。
作者: 任聪聪
独立博客:https://rccblogs.com/630.html
日期:2024年8月28日
详细报文信息:
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.13.0-runtime (androidx.core:core:1.13.0) 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.13.0-runtime (androidx.core:core:1.13.0) 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.13.0-runtime (androidx.core:core:1.13.0) 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.13.0-runtime (androidx.core:core:1.13.0) 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.13.0-runtime (androidx.core:core:1.13.0) 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.13.0-runtime (androidx.core:core:1.13.0) 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.13.0-runtime (androidx.core:core:1.13.0) 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.13.0-runtime (androidx.core:core:1.13.0) 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.13.0-runtime (androidx.core:core:1.13.0) 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.13.0-runtime (androidx.core:core:1.13.0) and support-compat-27.1.1-runtime (com.android.support:supp
主要原因说明:
这是由于已经导入的依赖中有涵盖相同core版本的情况,最终导致冲突报错,解决这个办法也很简单,找到那个冲突的依赖删掉或者换成其他依赖,但这种方法不建议,使用下面的解决办法可以不需要进行删除冲突依赖同样解决问题。
解决办法:
在文件 gradle.properties (根目录下的) 写入内容:
android.useAndroidX=true
android.enableJetifier=true
即可解决这个报错。