我已从Android支持库升级到Androidx。从那时起,我在运行程序时遇到此错误:
“程序类型已存在:com.google.common.util.concurrent.ListenableFuture”。
I have tried adding the following line to build.gradle file but still the error persists.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
我将我的build.gradle文件代码附加如下:
apply plugin: 'com.android.application'
android {
commpileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId 'com.test.free'
minSdkVersion 14
targetSdkVersion 26
versionCode 48
versionName '11.1'
multiDexEnabled true
signingConfig signingConfigs.free
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.free
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta01'
implementation 'com.google.android.material:material:1.1.0-alpha08'
implementation 'com.google.android.gms:play-services-ads:17.0.0'
implementation('com.google.api-client:google-api-client-android:1.25.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-youtube:v3-rev206-1.25.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.wang.avi:library:2.1.3'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
}
我无法解决此问题,因此需要一些助手。
答案 0 :(得分:0)
将此添加到应用程序的模块build.gradle:
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
之所以会发生这种情况,是因为某些依赖项使用com.google.guava:guava
,而有些则使用com.google.guava:listenablefuture
,并且它们一起导致依赖项冲突。