After upgrade android version getting “Duplicate class android.support.v4.app.INotificationSideChannel”

后端 未结 3 856
无人及你
无人及你 2020-12-15 07:24

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

\"Duplicate class android.support.v4.         


        
相关标签:
3条回答
  • 2020-12-15 07:43

    You have androidx libraries (probably in one of the used libraries) conflicting with the support libraries.

    Add these lines into your gradle.properties file: (It's in the root directory of your project)

    android.useAndroidX=true
    android.enableJetifier=true
    

    The Jetifier tool migrates support-library-dependent libraries to rely on the equivalent AndroidX packages instead.

    0 讨论(0)
  • 2020-12-15 07:46

    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

    0 讨论(0)
  • 2020-12-15 07:59

    First Select Refractor from top bar then from that select refract to androidx so it will create a zip file for you as a back up.

    After that it will automatically be fine and fixes all kind of bugs and errors that are stopping the phone app from running

    That's it!! You did it

    0 讨论(0)
提交回复
热议问题