错误:程序类型已存在:okhttp3.Address

问题描述 投票:0回答:1

我添加了一个新的jar文件作为模块,并面临上述问题。我已经在我的应用程序gradle文件中实现了okHttp。似乎jar文件也实现了相同的功能。知道怎么解决吗?

编辑** - 发布我的应用程序构建gradle文件。我已将库添加为项目,您也可以看到我在哪里实现了OkHttp库

apply plugin: 'com.android.application'


android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.bestdocapp.kiosk_opd"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
    debug {
        debuggable true
        applicationIdSuffix '.debug'
        versionNameSuffix '-DEBUG'


    }

    staging {
        debuggable true
        applicationIdSuffix ".debugStaging"
        versionNameSuffix '-STAGING'
        resValue "string", "app_name", "Kiosk Live"
    }



    release {
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        resValue "string", "app_name", "Kiosk"
        debuggable true
    }
}
dataBinding {
    enabled = true
}

compileOptions {
    targetCompatibility 1.8
    sourceCompatibility 1.8
}

}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.wdullaer:materialdatetimepicker:3.6.0'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.wdullaer:materialdatetimepicker:3.6.0'
implementation 'com.brandongogetap:stickyheaders:0.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation (project(':library_name'))

}

android retrofit okhttp
1个回答
0
投票

我有一个非常相似的问题。当我构建时,在dexing过程中它会抛出这个构建错误:

Program type already present: okhttp3.Address

并且在发生错误的Android Studio中建议我通过转到Google的文档中的此页面来解决:https://developer.android.com/studio/build/dependencies#duplicate_classes

我刚刚更新了谷歌服务

classpath 'com.google.gms:google-services:4.2.0'

所以因为谷歌的代码包含了Okhttp代码而引发了冲突。所以我完全删除了okhttp .jar文件和支持的okio .jar文件。推断如果Google包含Okhttp代码我不再需要它们了。这完全解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.