Since my android studio updated a couple of days ago, I have been struggling to get my application running again due to this error.
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)}
Here is my 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'
}
This code was working fine for me last week. However as I am fairly new to android development, I may have overlooked something. Any help would be appreciated, thank you.
Just try add exclude module: 'guava-jdk5'
to google apis imports like this:
implementation('com.google.api-client:google-api-client-android:1.20.0') {
exclude module: 'guava-jdk5'
}
If all fails, try:
[app/build.gradle]
configurations {
all*.exclude module: 'guava-jdk5'
}
As for my case, I'm using google-api-services-tasks
and google-api-client-android
. By checking the dependencies, I noticed that they both use 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 (*)
Once I excluded guava-jdk5
from both, the error message went away.
[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'
}
Change Gradles To This:
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'
It Worked For Me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With