程序类型已经存在:com.squareup.okhttp.Address [英] Program type already present: com.squareup.okhttp.Address

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

问题描述

我正在尝试将我的Android应用程序配置为使用Firebase Cloud Firestore.我也有对OKHttp3的依赖. Gradle可以很好地同步,但是我无法编译该应用程序并运行它.我收到以下错误:

I am trying to configure my android app to use Firebase Cloud Firestore. I also have dependencies on OKHttp3. Gradle will sync fine but I am unable to compile the app and run it. And I get the following error:

程序类型已经存在:com.squareup.okhttp.Address

Program type already present: com.squareup.okhttp.Address

我已按照此处描述的所有步骤操作: https://firebase.google.com/docs/firestore/quickstart ,直到我将此行添加到build.gradle文件中为止,我都可以正常运行该应用程序:

I have followed all the steps described here: https://firebase.google.com/docs/firestore/quickstart and I can run the app fine until I add this line to my build.gradle file:

implementation 'com.google.firebase:firebase-database:15.0.0'

我检查了项目中的依赖项,看起来Firestore依赖于com.squareup.okhttp,而我已经依赖于com.squareup.okhttp3

I checked the dependencies in the project and it looks like Firestore has dependencies on com.squareup.okhttp while I already have dependencies on com.squareup.okhttp3

所以我不明白为什么它们会发生冲突,因为它们具有不同的程序包结构.

So I don't understand why they would clash since they have different package structures.

编辑

这是我在build.gradle中的依赖项:

Here are my dependencies in my build.gradle:

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlin_version}"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.19.3'
implementation 'com.jakewharton:butterknife:8.8.0'
kapt 'com.jakewharton:butterknife-compiler:8.8.0'
compileOnly 'com.google.auto.value:auto-value:1.3'
annotationProcessor 'com.google.auto.value:auto-value:1.3'
implementation "com.android.support:design:${rootProject.ext.support_library_version}"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation "com.android.support:support-compat:${rootProject.ext.support_library_version}"
implementation "com.android.support:support-core-utils:${rootProject.ext.support_library_version}"
implementation "com.android.support:support-core-ui:${rootProject.ext.support_library_version}"
implementation "com.android.support:support-fragment:${rootProject.ext.support_library_version}"
implementation "com.android.support:gridlayout-v7:${rootProject.ext.support_library_version}"
implementation "com.android.support:recyclerview-v7:${rootProject.ext.support_library_version}"
implementation "com.android.support:customtabs:${rootProject.ext.support_library_version}"
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.google.code.gson:gson:2.8.0'
implementation "com.google.android.gms:play-services-auth:${rootProject.ext.play_services_version}"
implementation "com.google.android.gms:play-services-maps:${rootProject.ext.play_services_version}"
implementation "com.google.android.gms:play-services-location:${rootProject.ext.play_services_version}"
implementation "com.google.android.gms:play-services-analytics:${rootProject.ext.play_services_version}"
implementation "com.google.android.gms:play-services-wallet:${rootProject.ext.play_services_version}"
implementation "com.google.firebase:firebase-core:${rootProject.ext.firebase_version}"
implementation "com.google.firebase:firebase-crash:${rootProject.ext.firebase_version}"
implementation "com.google.firebase:firebase-messaging:${rootProject.ext.firebase_version}"
implementation "com.google.firebase:firebase-invites:${rootProject.ext.firebase_version}"
implementation "com.google.firebase:firebase-ads:${rootProject.ext.firebase_version}"

// Because RxAndroid releases are few and far between, it is recommended you also

// explicitly depend on RxJava's latest version for bug fixes and new features.
implementation 'io.reactivex.rxjava2:rxjava:2.0.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.0') {
    transitive = true
}
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'com.facebook.android:facebook-android-sdk:4.13.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'io.card:android-sdk:5.4.2'
implementation 'com.github.chrisbanes.photoview:library:1.2.3'
implementation 'uk.co.chrisjenx:calligraphy:2.1.0'
implementation 'com.tonicartos:superslim:0.4.13'
implementation 'com.sothree.slidinguppanel:library:3.1.1'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'konifar:fab-transformation:1.0.0'
implementation 'me.grantland:autofittextview:0.2.1'
implementation 'com.braintreepayments.api:braintree:2.3.3'
implementation 'se.emilsjolander:stickylistheaders:2.7.0'
implementation 'net.danlew:android.joda:2.9.4.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'ru.gildor.coroutines:kotlin-coroutines-retrofit:0.9.0'

testImplementation 'junit:junit:4.12'
testImplementation 'org.powermock:powermock-module-junit4:1.7.1'
testImplementation 'org.powermock:powermock-module-junit4-rule:1.7.1'
testImplementation 'org.powermock:powermock-api-mockito2:1.7.1'
testImplementation 'org.powermock:powermock-classloading-xstream:1.7.1'
testImplementation 'org.robolectric:robolectric:3.6.1'
testImplementation 'org.robolectric:shadows-multidex:3.6.1'
testImplementation 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.8.9'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
testImplementation 'joda-time:joda-time:2.9.4'
androidTestImplementation fileTree(include: 'robotium-solo-5.3.0.jar', dir: 'libs')

//Screenshots
androidTestImplementation 'com.squareup.spoon:spoon-client:1.2.0'

// Cucumber
androidTestImplementation 'info.cukes:cucumber-java:1.2.5'
androidTestImplementation('info.cukes:cucumber-android:1.2.4') {
    exclude module: 'cucumber-jvm-deps'
}
androidTestImplementation('info.cukes:cucumber-picocontainer:1.2.4') {
    exclude module: 'cucumber-jvm-deps'
}
androidTestImplementation 'info.cukes:cucumber-jvm-deps:1.0.3'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support:support-annotations:25.3.1'

// Set this dependency to use JUnit 4 rules
androidTestImplementation 'com.android.support.test:rules:0.5'

// Set this dependency to build and run Espresso tests
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2') {
    exclude module: 'support-annotations'
}
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:2.2.2'

}

推荐答案

已修复

事实证明问题与OkHttp无关-它与新版android studio(3.0.0及更高版本)中的Dexer编译器有关 进入gradle.properties文件并添加以下行:

FIXED

It turned out the problem was not related to OkHttp - it was related to the Dexer compiler in the new version of android studio (3.0.0 and above) Going into the gradle.properties file and adding this line:

android.enableD8=false

解决了我的问题.该应用现在可以正常编译

solved my problem. The app now compiles normally

评论正确-您应该执行此操作.问题原来是该项目具有gradle依赖项,与手动导入的.jar文件冲突.如果确实有此问题,请检查是否没有:

The comments are right - you should NOT do this. The problem turned out to be that the project had gradle dependencies conflicting with .jar files manually imported. If you do have this problem, check if you've not got:

  1. 由Gradle中的不同模块导入的同一库的不同版本
  2. 您也要通过Gradle导入的库的JAR文件

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

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆