从 androidx.core:core:1.0.0 和 com.android.support:support-compat:26.1.0 复制 class
Duplicate class from androidx.core:core:1.0.0 and com.android.support:support-compat:26.1.0
这是我的 build.gradle
:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 26
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
buildTypes {
debug {
debuggable true
buildConfigField "boolean", "CRASH_LOGGING", "true"
applicationIdSuffix ".dev"
}
release {
debuggable false
buildConfigField "boolean", "CRASH_LOGGING", "true"
minifyEnabled true
proguardFiles 'proguard-project.txt'
}
}
flavorDimensions "regular"
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
implementation "com.android.support:support-compat:26.1.0"
compile 'com.google.android.gms:play-services-auth:16.0.1'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile('com.thoughtworks.xstream:xstream:1.4.7') {
exclude group: 'xmlpull', module: 'xmlpull'
}
compile 'org.apache.commons:commons-lang3:3.6'
compile 'joda-time:joda-time:2.9.9'
compile('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
// UI & VIEWS
compile 'com.tuyenmonkey:mkloader:1.4.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.github.mmin18:realtimeblurview:1.1.0'
compile 'com.github.PhilJay:ValueBar:v1.0.2'
// IMAGE HANDLING
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
// NETWORK HANDLING
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
//RETORFIT
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile('com.squareup.retrofit2:converter-simplexml:2.3.0') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
// FABRIC
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true;
}
// ADS
compile 'com.flurry.android:analytics:8.2.0@aar'
compile 'com.appbrain:appbrain-sdk:14.60@aar'
compile(name: 'android-ad-sdk', ext: 'aar')
compile(name: 'SOMAAndroid-9.1.5-release', ext: 'aar')
compile 'com.applovin:applovin-sdk:+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
samsungDebugImplementation files('libs/sdk-v1.0.0.jar')
samsungDebugImplementation files('libs/motion-v2.2.2.jar')
samsungReleaseImplementation files('libs/sdk-v1.0.0.jar')
samsungReleaseImplementation files('libs/motion-v2.2.2.jar')
//debug DB
debugCompile 'com.amitshekhar.android:debug-db:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
当我升级这条线路时:
compile 'com.google.android.gms:play-services-ads:18.3.0'
我收到这个错误:
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
这是 build.gradle
文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.10"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.google.gms:google-services:4.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
// For MobFox
maven {
url "https://jitpack.io"
}
// For AppBrain SDK
maven {
url 'http://swisscodemonkeys.github.io/appbrain-sdk/maven'
}
}
}
知道是什么造成了这个重复错误吗?我该如何解决?
在你的gradle.properties中添加
android.useAndroidX=true
android.enableJetifier=true
请尝试 Refactor > 迁移到 AndroidX 然后按 Do Refactor
引自official doc、
With Android Studio 3.2 and higher, you can migrate an existing
project to AndroidX by selecting Refactor > Migrate to AndroidX
from the menu bar.
The refactor command makes use of two flags. By default, both of them
are set to true in your gradle.properties
file:
android.useAndroidX=true
The Android plugin uses the appropriate AndroidX library instead of a
Support Library.
android.enableJetifier=true
The Android plugin automatically migrates existing third-party
libraries to use AndroidX by rewriting their binaries.
您升级 google play services 依赖项而没有检查文档:https://developers.google.com/android/guides/releases,它清楚地表明 google play services ads 18.0.0 您的项目中需要 androidX。所以现在将您的项目更新为 Android X.
选项 1:使用 com.google.android.gms:play-services-ads:17.2.1,不推荐,因为您必须使用最新的依赖项。
或
选项 2:转到 Android Studio(使用最新的 Android studio)-> 重构 -> 迁移到 AndroidX。 Zip/backup 您的项目和 运行 迁移。
这是我的 build.gradle
:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 26
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
buildTypes {
debug {
debuggable true
buildConfigField "boolean", "CRASH_LOGGING", "true"
applicationIdSuffix ".dev"
}
release {
debuggable false
buildConfigField "boolean", "CRASH_LOGGING", "true"
minifyEnabled true
proguardFiles 'proguard-project.txt'
}
}
flavorDimensions "regular"
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
implementation "com.android.support:support-compat:26.1.0"
compile 'com.google.android.gms:play-services-auth:16.0.1'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile('com.thoughtworks.xstream:xstream:1.4.7') {
exclude group: 'xmlpull', module: 'xmlpull'
}
compile 'org.apache.commons:commons-lang3:3.6'
compile 'joda-time:joda-time:2.9.9'
compile('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
// UI & VIEWS
compile 'com.tuyenmonkey:mkloader:1.4.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.github.mmin18:realtimeblurview:1.1.0'
compile 'com.github.PhilJay:ValueBar:v1.0.2'
// IMAGE HANDLING
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
// NETWORK HANDLING
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
//RETORFIT
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile('com.squareup.retrofit2:converter-simplexml:2.3.0') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
// FABRIC
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true;
}
// ADS
compile 'com.flurry.android:analytics:8.2.0@aar'
compile 'com.appbrain:appbrain-sdk:14.60@aar'
compile(name: 'android-ad-sdk', ext: 'aar')
compile(name: 'SOMAAndroid-9.1.5-release', ext: 'aar')
compile 'com.applovin:applovin-sdk:+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
samsungDebugImplementation files('libs/sdk-v1.0.0.jar')
samsungDebugImplementation files('libs/motion-v2.2.2.jar')
samsungReleaseImplementation files('libs/sdk-v1.0.0.jar')
samsungReleaseImplementation files('libs/motion-v2.2.2.jar')
//debug DB
debugCompile 'com.amitshekhar.android:debug-db:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
当我升级这条线路时:
compile 'com.google.android.gms:play-services-ads:18.3.0'
我收到这个错误:
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0)
这是 build.gradle
文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.10"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.google.gms:google-services:4.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
// For MobFox
maven {
url "https://jitpack.io"
}
// For AppBrain SDK
maven {
url 'http://swisscodemonkeys.github.io/appbrain-sdk/maven'
}
}
}
知道是什么造成了这个重复错误吗?我该如何解决?
在你的gradle.properties中添加
android.useAndroidX=true
android.enableJetifier=true
请尝试 Refactor > 迁移到 AndroidX 然后按 Do Refactor
引自official doc、
With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
The refactor command makes use of two flags. By default, both of them are set to true in your
gradle.properties
file:
android.useAndroidX=true
The Android plugin uses the appropriate AndroidX library instead of a Support Library.
android.enableJetifier=true
The Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries.
您升级 google play services 依赖项而没有检查文档:https://developers.google.com/android/guides/releases,它清楚地表明 google play services ads 18.0.0 您的项目中需要 androidX。所以现在将您的项目更新为 Android X.
选项 1:使用 com.google.android.gms:play-services-ads:17.2.1,不推荐,因为您必须使用最新的依赖项。
或
选项 2:转到 Android Studio(使用最新的 Android studio)-> 重构 -> 迁移到 AndroidX。 Zip/backup 您的项目和 运行 迁移。