本文介绍了程序类型已经存在:okhttp3.Call $ Factory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的Android项目,该项目拒绝在Android Studio中进行构建,只是给了我这个神秘的错误消息:

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)}

这是我的依赖项:

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')
}

如何解决该问题?

推荐答案

您的一个.jar应该已经包含 okHttp3 ,这可能就是为什么 implementation'com出现问题的原因.squareup.okhttp3:okhttp:3.10.0'.

One of your .jar should already contain okHttp3, and this is probably why there is an issue with implementation 'com.squareup.okhttp3:okhttp:3.10.0'.

如果删除此依赖项,则不会收到错误消息.

If you remove this dependency, you should not get the error.

您可以打印与 gradlew app:dependencies 一起使用的所有依赖关系的树(其中app是用于您的应用程序的模块的名称,通常是创建新android时的默认名称应用项目)

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)

这篇关于程序类型已经存在:okhttp3.Call $ Factory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 20:28