【问题标题】:Program type already present: okhttp3.Call$Factory程序类型已经存在:okhttp3.Call$Factory
【发布时间】:2018-04-30 10:37:41
【问题描述】:

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

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

我该如何解决这个问题?

【问题讨论】:

    标签: android android-studio android-gradle-plugin


    【解决方案1】:

    您的一个 .jar 应该已经包含 okHttp3,这可能就是 implementation 'com.squareup.okhttp3:okhttp:3.10.0' 存在问题的原因。

    如果你删除这个依赖,你应该不会得到错误。

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

    【讨论】:

    • 我没有直接使用 okhtpp3 库,但我使用的是 twitter 的核心库,其中包括 okhttp3 库,那我该怎么办?我必须同时使用 twitter 核心和 ksoap2(这会导致崩溃)
    猜你喜欢
    • 2018-11-30
    • 1970-01-01
    • 2018-12-23
    • 2017-08-24
    • 1970-01-01
    • 2018-09-23
    • 2019-02-22
    • 1970-01-01
    • 2018-10-21
    相关资源
    最近更新 更多