Android 库给出重复错误的实现
我试图在我的项目中实现'com.github.barteksc:android pdf viewer:2.8.2',我能够同步gradle文件,但当我尝试启动应用程序时,它会给我这个错误Android 库给出重复错误的实现,android,implementation,Android,Implementation,我试图在我的项目中实现'com.github.barteksc:android pdf viewer:2.8.2',我能够同步gradle文件,但当我尝试启动应用程序时,它会给我这个错误 Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.5.0- runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-r
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.5.0-
runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)
Go to the documentation to learn how to Fix dependency resolution errors
我不明白为什么我会在下面发布build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.jenson.resumeapp"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
我似乎找不到任何有效的方法?在gradle.properties文件中添加这些行
android.useAndroidX = true
android.enableJetifier = true
我在实施时遇到了同样的问题: com.github.shts:StoriesProgressView:3.0.0 至少在我的例子中,问题是StoriesProgesView依赖项正在从com.android.support:support compat检索同一个类,该类现在已经存在于androidx核心包中,导致冲突加剧 我就是这样做的: 通过查看依赖关系树,我发现StoriesProgressView引入了这些依赖关系,为了删除这些依赖关系,我向依赖关系添加了exlusion规则,如下所示:
implementation ('com.github.shts:StoriesProgressView:3.0.0') {
exclude group: "com.android.support", module: "support-compat"
exclude group: "com.android.support", module: "support-media-compat"
}
这停止了从旧包中提取类
不过,在您的情况下,似乎没有任何第三方依赖关系,所以遵循Malik Ali的答案就足够了。如果不行,就试试这个 可能是缓存问题,请尝试以下两个简单步骤1。使缓存无效,然后重新启动2。清理并重建项目,然后再试一次。尝试了没有效果,得到相同的错误我只需要添加android。enableJetifier=true,但是如果你没有另一个,我会说。我已经有了最好的