使用“ Cxense Android版SDK” ,我收到重复类的消息:
Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (**com.android.support:support-compat:27.1.1**) and classes.jar (**com.android.support:support-v4:22.2.0**)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (com.android.support:support-compat:27.1.1) and classes.jar (com.android.support:support-v4:22.2.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules classes.jar (com.android.support:support-compat:27.1.1) and classes.jar (com.android.support:support-v4:22.2.0)
Duplicate class android.support.v4.app.ListFragment found in modules classes.jar (com.android.support:support-fragment:27.1.1) and classes.jar (com.android.support:support-v4:22.2.0)
Duplicate class android.support.v4.app.ListFragment$1 found in modules classes.jar (com.android.support:support-fragment:27.1.1) and classes.jar (com.android.support:support-v4:22.2.0)
Duplicate class android.support.v4.app.ListFragment$2 found in modules classes.jar (com.android.support:support-fragment:27.1.1) and classes.jar (com.android.support:support-v4:22.2.0)
Duplicate class android.support.v4.app.LoaderManager found in modules classes.jar (com.android.support:support-fragment:27.1.1) and classes.jar (com.android.support:support-v4:22.2.0)
这是我的应用程序级别 build.gradle 配置:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.tototita.cxensetestapp"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//**CXsense
implementation 'com.cxpublic:cxense-android:1.0.1'
}
如何避免Cxense SDK中肯定包含这些重复的类?
答案 0 :(得分:2)
如果有重复项,请使用exclude
:
implementation ('com.cxpublic:cxense-android:1.0.1') {
exclude group: "com.android.support", module: "support-v4"
}
或以implementation 'com.android.support:appcompat-v7:27.1.1'
的名义删除support-v4
。
答案 1 :(得分:1)
有两种方法可以解决您的问题。
排除重复的依赖项,而implementation
分别
以通用方式从每个implementation
中排除重复的依赖项。
在这种情况下,工件 com.android.support
是重复的,因为您的 app模块使用的版本是 27.1.1 工件 com.cxpublic:cxense-android:1.0.1
的内部依赖性为 com.android.support
使用版本: 22.2.0 。
因此,您应该手动删除其中之一(建议删除旧版本或较低版本)。让我们尝试将其删除!
第一种方法:
implementation ('com.cxpublic:cxense-android:1.0.1') {
exclude group: "com.android.support", module: "support-v4"
}
在我们的工件com.android.support
中为组 com.cxpublic:cxense-android:1.0.1
放入排除不会为 { {1}} 库,当我们在此工件上使用实现时。
因此,可以通过手动将此块放置到每个有此冲突的工件来解决问题。
通过第二种方式:
我们可以删除包含的依赖项,并用具有最新编号的软件包替换它们。在我们的情况下,它是 support-v4
,具有不同的版本。因此,转到应用程序级别 build.gradle 的android块,并将其放在该块的下面,以从所有工件中删除重复的 support-v4
,以便我们可以将依赖性。
support-v4