升级 android 版本后得到“Duplicate class android.support.v4.app.INotificationSideChannel"

After upgrade android version getting quot;Duplicate class android.support.v4.app.INotificationSideChannelquot;(升级 android 版本后得到“Duplicate class android.support.v4.app.INotificationSideChannel)

本文介绍了升级 android 版本后得到“Duplicate class android.support.v4.app.INotificationSideChannel"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 android update 3.4 之前,我的应用程序运行完美,但在升级 android 之后,我的应用程序出现合并错误:

"重复类 android.support.v4.app.INotificationSideChannel"安卓更新3.4升级等级 5.1.1升级sdk错误:在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.app.INotificationSideChannel在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.app.INotificationSideChannel$Stub在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.app.INotificationSideChannel$Stub$Proxy)在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.graphics.drawable.IconCompatParcelizer在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.os.IResultReceiver在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.os.IResultReceiver$Stub在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.os.IResultReceiver$Stub$Proxy)在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.os.ResultReceiver在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.os.ResultReceiver$1在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.os.ResultReceiver$MyResultReceiver在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.os.ResultReceiver$MyRunnable在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 androidx.core.graphics.drawable.IconCompatParcelizer在模块 classes.jar (androidx.core:core:1.0.0) 和 classes.jar (com.android.support:support-compat:28.0.0) 中发现重复的类 androidx.core.internal.package-info在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.CustomVersionedParcelable在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.NonParcelField在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.ParcelField在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.ParcelImpl在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.ParcelImpl$1在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.ParcelUtils在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.VersionedParcel在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.VersionedParcel$1在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.VersionedParcel$ParcelException在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.VersionedParcelParcel在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.VersionedParcelStream在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.VersionedParcelStream$FieldBuffer在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.VersionedParcelStream$InputBuffer在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.VersionedParcelable在模块 classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) 和 classes.jar (com.android.support:versionedparcelable:28.0.0) 中发现重复的类 androidx.versionedparcelable.VersionedParcelize转到文档以了解如何修复依赖关系解析错误.

--------------------依赖------------

依赖项{实现文件树(包括:['*.jar'],目录:'libs')//无检查 GradleCompatible实施 'com.android.support:appcompat-v7:28.0.0'实施 'com.android.support:design:28.0.0'//无检查 GradleCompatible//实现 'com.android.support:appcompat-v7:28.0.0'实施 'com.android.support:support-compat:28.0.0'实施 'com.android.support.constraint:constraint-layout:2.0.0-alpha4'//实现 'com.android.support:design:28.0.0'testImplementation 'junit:junit:4.13-beta-2'androidTestImplementation 'com.android.support.test:runner:1.0.2'androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'//凌空抽射实施 'com.android.volley:volley:1.1.0'//裁剪图片库...实现 'com.theartofdev.edmodo:android-image-cropper:2.8.0'//牛油刀实施 'com.jakewharton:butterknife:8.8.1'annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'//改造实施 'com.squareup.retrofit2:retrofit:2.5.0'实施 'com.squareup.retrofit2:converter-gson:2.5.0'实现 'com.squareup.retrofit2:adapter-rxjava:2.5.0'实现 'io.reactivex:rxandroid:1.2.1'实现 'com.github.traex.rippleeffect:library:1.3'//谷歌播放服务实施 'com.google.android.gms:play-services-location:16.0.0'实施 'com.google.android.gms:play-services-maps:16.1.0'//gson实施 'com.google.code.gson:gson:2.8.5'//房间实施 'android.arch.persistence.room:runtime:1.1.1'实施 'com.android.support:support-v4:28.0.0'注释处理器android.arch.persistence.room:compiler:1.1.1"实施 'org.jsoup:jsoup:1.11.3'//cardview &回收站视图实施 'com.android.support:cardview-v7:28.0.0'实施 'com.android.support:recyclerview-v7:28.0.0'//毕加索实施 'com.squareup.picasso:picasso:2.71828'实现 'com.android.support:support-annotations:28.0.0'实施 'de.hdodenhof:circleimageview:3.0.0'实施 'com.karumi:dexter:5.0.0'实现 'com.journeyapps:zxing-android-embedded:3.4.0'//火力基地实施 'com.google.firebase:firebase-core:16.0.8'实施 'com.google.firebase:firebase-ml-vision:19.0.3'//firebase-云按摩..实施 'com.google.firebase:firebase-messaging:17.6.0'实现org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"}

解决方案

为什么会这样?

因为升级后,androidx.core:core 在某处被访问,此时您的项目仍未使用 androidx.所以像 INotificationSideChannel 和许多其他类现在可以在两个地方找到 - androidx.core:corecom.android.support:support-compat.这就是发生此错误的原因.

解决方案?

您需要迁移到您应该已经完成​​的 AndroidX.如果您不了解 AndroidX.请阅读

<块引用>

新项目

将这些标志放在你的 gradle.properties

android.enableJetifier=trueandroid.useAndroidX=true

检查@同等AndroidX包的库映射.

查看@Migrate to AndroidX官方页面

before android update 3.4 my application run perfectly but after upgrade android my application getting merging error:

"Duplicate class android.support.v4.app.INotificationSideChannel"

android update 3.4
upgrade gradle 5.1.1 
upgrade sdk

Error:
    Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.os.IResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.os.ResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.os.ResultReceiver$1 found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class androidx.core.graphics.drawable.IconCompatParcelizer found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class androidx.core.internal.package-info found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:28.0.0)
    Duplicate class androidx.versionedparcelable.CustomVersionedParcelable found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.NonParcelField found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.ParcelField found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.ParcelImpl found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.ParcelImpl$1 found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.ParcelUtils found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.VersionedParcel found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.VersionedParcel$1 found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.VersionedParcel$ParcelException found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.VersionedParcelParcel found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.VersionedParcelStream found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.VersionedParcelStream$FieldBuffer found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.VersionedParcelStream$InputBuffer found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.VersionedParcelable found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
    Duplicate class androidx.versionedparcelable.VersionedParcelize found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)

Go to the documentation to learn how to Fix dependency resolution errors.

------------------DEPENDENCY------------

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    //noinspection GradleCompatible
//    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-compat:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha4'
//    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.13-beta-2'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    //volley
    implementation 'com.android.volley:volley:1.1.0'
    //crop image library...
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
    //ButterKnife
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    //retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.5.0'
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'com.github.traex.rippleeffect:library:1.3'
    //Google play services
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    //gson
    implementation 'com.google.code.gson:gson:2.8.5'
    // Room
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    implementation 'com.android.support:support-v4:28.0.0'
    annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
    implementation 'org.jsoup:jsoup:1.11.3'
    //cardview & recyclerview
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    //picasoo
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.karumi:dexter:5.0.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
    //firebase
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-ml-vision:19.0.3'
    //firebase-cloud massaging..
    implementation 'com.google.firebase:firebase-messaging:17.6.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

解决方案

Why did this happen?

Because after upgrade, androidx.core:core is accessed somewhere, when your project is still not using androidx. So classes like INotificationSideChannel and many others are now found at two places - androidx.core:core and com.android.support:support-compat. That's why this error occured.

Solution?

You need to migrate to AndroidX which you should have done already. If you don't know about AndroidX. Please read What is AndroidX?

How to migrate current project

In Android Studio 3.2 (September 2018), there is direct option to migrate existing project to AndroidX. This refract all packages automatically.

Before you migrate, it is strongly recommended to backup your project.

Existing project

  • Android Studio > Refactor Menu > Migrate to AndroidX...
  • It will analysis and will open Refractor window in bottom. Accept changes to be done.

New project

Put these flags in your gradle.properties

android.enableJetifier=true
android.useAndroidX=true

Check @Library mappings for equal AndroidX package.

Check @Official page of Migrate to AndroidX

这篇关于升级 android 版本后得到“Duplicate class android.support.v4.app.INotificationSideChannel"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:升级 android 版本后得到“Duplicate class android.support.v4.app.INotificationSideChannel"

基础教程推荐