• androidx和v4包资源冲突解决方法


    一、资源包会报如下错误:

    错误类似 (androidx.core:core:1.10.0) 和 (com.android.support:support-compat:24.2.0)

    表示资源重复,不知调用androidx包下面的,还是v4包下面的

    1. Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)
    2. Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)
    3. Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)
    4. Duplicate class android.support.v4.media.MediaBrowserCompat found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    5. Duplicate class android.support.v4.media.MediaBrowserCompat$CallbackHandler found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    6. Duplicate class android.support.v4.media.MediaBrowserCompat$ConnectionCallback found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    7. Duplicate class android.support.v4.media.MediaBrowserCompat$ConnectionCallback$ConnectionCallbackInternal found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    8. Duplicate class android.support.v4.media.MediaBrowserCompat$ItemCallback found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    9. Duplicate class android.support.v4.media.MediaBrowserCompat$ItemReceiver found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    10. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImpl found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    11. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    12. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    13. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$2 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    14. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$3 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    15. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi23 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    16. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    17. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    18. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$2 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    19. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$3 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    20. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$MediaServiceConnection found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    21. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$MediaServiceConnection$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    22. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$MediaServiceConnection$2 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    23. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserServiceCallbackImpl found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    24. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaItem found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    25. Duplicate class android.support.v4.media.MediaBrowserCompat$MediaItem$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    26. Duplicate class android.support.v4.media.MediaBrowserCompat$ServiceBinderWrapper found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    27. Duplicate class android.support.v4.media.MediaBrowserCompat$Subscription found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    28. Duplicate class android.support.v4.media.MediaBrowserCompat$SubscriptionCallback found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    29. Duplicate class android.support.v4.media.MediaDescriptionCompat found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    30. Duplicate class android.support.v4.media.MediaDescriptionCompat$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    31. Duplicate class android.support.v4.media.MediaDescriptionCompat$Builder found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    32. Duplicate class android.support.v4.media.MediaMetadataCompat found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    33. Duplicate class android.support.v4.media.MediaMetadataCompat$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    34. Duplicate class android.support.v4.media.MediaMetadataCompat$Builder found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    35. Duplicate class android.support.v4.media.RatingCompat found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    36. Duplicate class android.support.v4.media.RatingCompat$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    37. Duplicate class android.support.v4.media.RatingCompat$StarStyle found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    38. Duplicate class android.support.v4.media.RatingCompat$Style found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    39. Duplicate class android.support.v4.media.session.IMediaControllerCallback found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    40. Duplicate class android.support.v4.media.session.IMediaControllerCallback$Stub found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    41. Duplicate class android.support.v4.media.session.IMediaControllerCallback$Stub$Proxy found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    42. Duplicate class android.support.v4.media.session.IMediaSession found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    43. Duplicate class android.support.v4.media.session.IMediaSession$Stub found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    44. Duplicate class android.support.v4.media.session.IMediaSession$Stub$Proxy found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    45. Duplicate class android.support.v4.media.session.MediaControllerCompat found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    46. Duplicate class android.support.v4.media.session.MediaControllerCompat$Callback found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    47. Duplicate class android.support.v4.media.session.MediaControllerCompat$Callback$MessageHandler found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    48. Duplicate class android.support.v4.media.session.MediaControllerCompat$Callback$StubCompat found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    49. Duplicate class android.support.v4.media.session.MediaControllerCompat$MediaControllerImpl found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    50. Duplicate class android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi21 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    51. Duplicate class android.support.v4.media.session.MediaControllerCompat$MediaControllerImplBase found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    52. Duplicate class android.support.v4.media.session.MediaControllerCompat$PlaybackInfo found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    53. Duplicate class android.support.v4.media.session.MediaControllerCompat$TransportControls found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    54. Duplicate class android.support.v4.media.session.MediaControllerCompat$TransportControlsApi21 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    55. Duplicate class android.support.v4.media.session.MediaControllerCompat$TransportControlsBase found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    56. Duplicate class android.support.v4.media.session.MediaSessionCompat found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    57. Duplicate class android.support.v4.media.session.MediaSessionCompat$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    58. Duplicate class android.support.v4.media.session.MediaSessionCompat$Callback found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    59. Duplicate class android.support.v4.media.session.MediaSessionCompat$MediaSessionImpl found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    60. Duplicate class android.support.v4.media.session.MediaSessionCompat$MediaSessionImplApi21 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    61. Duplicate class android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    62. Duplicate class android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    63. Duplicate class android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase$Command found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    64. Duplicate class android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase$MediaSessionStub found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    65. Duplicate class android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase$MessageHandler found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    66. Duplicate class android.support.v4.media.session.MediaSessionCompat$OnActiveChangeListener found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    67. Duplicate class android.support.v4.media.session.MediaSessionCompat$QueueItem found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    68. Duplicate class android.support.v4.media.session.MediaSessionCompat$QueueItem$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    69. Duplicate class android.support.v4.media.session.MediaSessionCompat$ResultReceiverWrapper found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    70. Duplicate class android.support.v4.media.session.MediaSessionCompat$ResultReceiverWrapper$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    71. Duplicate class android.support.v4.media.session.MediaSessionCompat$Token found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    72. Duplicate class android.support.v4.media.session.MediaSessionCompat$Token$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    73. Duplicate class android.support.v4.media.session.ParcelableVolumeInfo found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    74. Duplicate class android.support.v4.media.session.ParcelableVolumeInfo$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    75. Duplicate class android.support.v4.media.session.PlaybackStateCompat found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    76. Duplicate class android.support.v4.media.session.PlaybackStateCompat$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    77. Duplicate class android.support.v4.media.session.PlaybackStateCompat$Actions found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    78. Duplicate class android.support.v4.media.session.PlaybackStateCompat$Builder found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    79. Duplicate class android.support.v4.media.session.PlaybackStateCompat$CustomAction found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    80. Duplicate class android.support.v4.media.session.PlaybackStateCompat$CustomAction$1 found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    81. Duplicate class android.support.v4.media.session.PlaybackStateCompat$CustomAction$Builder found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    82. Duplicate class android.support.v4.media.session.PlaybackStateCompat$MediaKeyAction found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    83. Duplicate class android.support.v4.media.session.PlaybackStateCompat$State found in modules media-1.2.1-runtime (androidx.media:media:1.2.1) and support-media-compat-24.2.0-runtime (com.android.support:support-media-compat:24.2.0)
    84. Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)
    85. Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)
    86. Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)
    87. Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)
    88. Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)
    89. Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)
    90. Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.10.0-runtime (androidx.core:core:1.10.0) and support-compat-24.2.0-runtime (com.android.support:support-compat:24.2.0)

    二、 解决方法

    2.1 在gradle.properties中只添加了android.useAndroidX=true(表示当前项目启用 AndroidX)

    2.2 添加android.enableJetifier=true(表示将依赖包也迁移到AndroidX,将项目中用到的第三方库中的support引用转为androidx引用) 即可

    1. android.useAndroidX=true
    2. android.enableJetifier=true

  • 相关阅读:
    牛逼!2022 最新 Spring 面试题
    【Android -- 开发】中级工程师进阶
    ElasticSearch 学习1:linux 安装 ElasticSearch7.6.1
    windows频繁更新问题解决方案
    报名仅剩十天!又一开发者公布高分方案源代码,助力软件杯选手高效解题
    JavaWeb在线问题.Linux服务器MEM内存核查
    PHP 使用 Guzzle 执行 HTTP 请求
    1. STL六大组件
    bat 批示处理详解-2
    用java代码实现security
  • 原文地址:https://blog.csdn.net/hzqit520/article/details/133809864