【问题标题】:How to fix duplicate classes in gradle build for android studio如何修复 gradle build for android studio 中的重复类
【发布时间】:2019-09-02 16:54:20
【问题描述】:

我正在尝试在 build.gradle 中添加广告。但是,它似乎不起作用。

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "br.com.alessanderleite.catchtheballgame"
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android- 
optimize.txt'), 'proguard-rules.pro'
    }
    }
  }



dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-ads:9.4.0'
}

错误:

Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-v4:23.0.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-v4:23.0.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-v4:23.0.0)

转到文档以了解如何修复依赖项解析错误。

【问题讨论】:

    标签: android android-gradle-plugin admob google-play-services androidx


    【解决方案1】:

    你正在使用

    implementation 'com.google.android.gms:play-services-ads:9.4.0'
    

    此版本使用支持库,不能同时使用androidx和支持库。

    使用update version 的广告迁移到 androidx。

    implementation 'com.google.android.gms:play-services-ads:18.2.0'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-23
      • 2018-03-21
      • 1970-01-01
      • 2020-12-14
      • 1970-01-01
      • 2021-11-17
      • 1970-01-01
      相关资源
      最近更新 更多