自从几天前我的android工作室更新以来,由于这个错误,我一直在努力让我的应用程序再次运行。
Program type already present: com.google.common.annotations.Beta
Message{kind=ERROR, text=Program type already present:
com.google.common.annotations.Beta, sources=[Unknown source file], tool name=Optional.of(D8)}
这是我的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.dissertation.bitcoin.bitparking"
minSdkVersion 21
targetSdkVersion 27
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.android.support:appcompat-v7:27.1.0')
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.http-client:google-http-client-android:1.23.0'
implementation 'com.google.api-client:google-api-client-android:1.23.0'
implementation 'com.google.code.findbugs:jsr305:2.0.1'
implementation 'com.google.api-client:google-api-client-gson:1.23.0'
implementation 'com.googlecode.json-simple:json-simple:1.1'
implementation files('libs/java-json.jar')
implementation 'com.android.support:support-compat:27.1.0'
implementation 'com.github.bumptech.glide:glide:4.3.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google:bitcoinj:0.11.3'
implementation 'de.schildbach.wallet:integration-android:2.0'
}
这个代码上周对我很好。然而,由于我对Android开发相当新,我可能忽略了一些东西。任何帮助将不胜感激,谢谢。
答案 0 :(得分:13)
尝试将exclude module: 'guava-jdk5'
添加到Google apis导入中,如下所示:
implementation('com.google.api-client:google-api-client-android:1.20.0') {
exclude module: 'guava-jdk5'
}
答案 1 :(得分:2)
至于我的情况,我使用google-api-services-tasks
和google-api-client-android
。通过检查依赖关系,我注意到它们都使用google-api-client
。
./gradlew app:dependencies
...
+--- com.google.api-client:google-api-client-android:1.23.0
| +--- com.google.api-client:google-api-client:1.23.0
| | +--- com.google.oauth-client:google-oauth-client:1.23.0
| | | +--- com.google.http-client:google-http-client:1.23.0
| | | | +--- com.google.code.findbugs:jsr305:1.3.9 -> 2.0.1
| | | | \--- org.apache.httpcomponents:httpclient:4.0.1
| | | | +--- org.apache.httpcomponents:httpcore:4.0.1
| | | | +--- commons-logging:commons-logging:1.1.1
| | | | \--- commons-codec:commons-codec:1.3
| | | \--- com.google.code.findbugs:jsr305:1.3.9 -> 2.0.1
| | +--- com.google.http-client:google-http-client-jackson2:1.23.0
| | | +--- com.google.http-client:google-http-client:1.23.0 (*)
| | | \--- com.fasterxml.jackson.core:jackson-core:2.1.3
| | \--- com.google.guava:guava-jdk5:17.0
| \--- com.google.http-client:google-http-client-android:1.23.0
| \--- com.google.http-client:google-http-client:1.23.0 (*)
+--- com.google.apis:google-api-services-tasks:v1-rev52-1.23.0
| \--- com.google.api-client:google-api-client:1.23.0 (*)
从两者中排除guava-jdk5
后,错误消息就消失了。
[app/build.gradle]
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude module: 'guava-jdk5'
}
implementation('com.google.apis:google-api-services-tasks:v1-rev52-1.23.0') {
exclude module: 'guava-jdk5'
}
答案 2 :(得分:2)
更改等级:
implementation 'com.google.apis:google-api-services-vision:v1-rev369-1.23.0' exclude module: 'guava-jdk5'
implementation 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'guava-jdk5' exclude module: 'httpclient'
implementation 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
对我有用
答案 3 :(得分:2)
如果全部失败,请尝试:
[app/build.gradle]
configurations {
all*.exclude module: 'guava-jdk5'
}
答案 4 :(得分:0)
如果您在项目中也使用Kotlin,请删除 来自build.gradle(app模块)的“kapt'com.android.databinding:compiler”。