I have a very simple Android project that refuses to build in Android Studio and just gives me this cryptic error message:
Program type already present: okhttp3.Call$Factory
Message{kind=ERROR, text=Program type already present: okhttp3.Call$Factory, sources=[Unknown source file], tool name=Optional.of(D8)}
Here are my dependencies:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'net.openid:appauth:0.7.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
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 files('libs/easywsdl/ksoap2-android-assembly-3.6.2-jar-with-dependencies.jar')
implementation files('libs/easywsdl/ExKsoap2-1.0.2.0.jar')
}
How can I troubleshoot that?
One of your .jar should already contain
okHttp3
, and this is probably why there is an issue withimplementation 'com.squareup.okhttp3:okhttp:3.10.0'
.If you remove this dependency, you should not get the error.
You can print a tree of all the dependencies used with
gradlew app:dependencies
(where app is the name of the module used for your application, and usually the default name when you create a new android app project)