【问题标题】:Duplicate class okhttp3.internal.ws.RealWebSocket found in modules jetified-okhttp-3.12.0 and jetified-okhttp-ws-3.4.1在模块 jetified-okhttp-3.12.0 和 jetified-okhttp-ws-3.4.1 中发现重复的类 okhttp3.internal.ws.RealWebSocket
【发布时间】:2021-10-13 23:07:42
【问题描述】:

我有一个类似的依赖错误

在模块 jetified-okhttp-3.12.0 (com.squareup.okhttp3:okhttp:3.12.0) 和 jetified-okhttp-ws-3.4.1 (com .squareup.okhttp3:okhttp-ws:3.4.1)

我正在使用 WebSocket 和 LoggingInterceptor 并实现了这两个依赖项, 下面是我的build.gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
}

android {
   
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.mrrights.harvestoperator"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            aaptOptions { cruncherEnabled = false }
            signingConfig signingConfigs.release
            multiDexEnabled true
        }


    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

        lintOptions {
            checkReleaseBuilds false
            // Or, if you prefer, you can continue to check for errors in release builds,
            // but continue the build even when errors are found:
            abortOnError false
        }

}

dependencies {

    //kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'

    //ui
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.work:work-runtime:2.4.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
    implementation "androidx.cardview:cardview:1.0.0"

    //google map & location
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-location:17.1.0'
    implementation 'com.google.android.libraries.places:places:2.4.0'
    implementation 'com.google.maps.android:maps-utils-ktx:2.2.0'

    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:26.1.0')

    // Firebase Messaging Service
    implementation 'com.google.firebase:firebase-messaging-ktx'

    // Firebase Analytics for Logs in server side
    implementation 'com.google.firebase:firebase-analytics-ktx'

    // Firebase Authentication
    implementation 'com.google.firebase:firebase-auth-ktx'
    // FirebaseUI (for authentication)
    implementation 'com.firebaseui:firebase-ui-auth:6.2.0'
    //firebase firestore
    implementation 'com.google.firebase:firebase-firestore-ktx'

    //firebase storage
    implementation 'com.google.firebase:firebase-storage-ktx'

    // FirebaseUI for Cloud Firestore
    implementation 'com.firebaseui:firebase-ui-firestore:7.1.1'
    implementation 'com.firebaseui:firebase-ui-storage:4.1.0'
    implementation 'com.google.firebase:firebase-storage:15.0.2'
    implementation 'com.google.firebase:firebase-crashlytics:17.3.1'
    implementation 'com.google.firebase:firebase-analytics:18.0.2'
    implementation 'com.android.support:cardview-v7:28.0.0'

    //Testing
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    //image view with URl
    implementation 'com.squareup.picasso:picasso:2.71828'

    //coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'

    //steps view
    implementation 'com.shuhart.stepview:stepview:1.5.1'

    //datePicker
    implementation 'com.vivekkaushik.datepicker:datePickerTimeline:0.0.4'

    //Retrofit, Interceptor, Json to Gson converter
    implementation 'com.squareup.retrofit2:retrofit:2.6.0'
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.12.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'

    implementation "androidx.multidex:multidex:2.0.1"
    implementation 'com.squareup.okhttp3:okhttp-ws:3.4.1'
    implementation "com.squareup.okhttp3:okhttp-urlconnection:3.4.1"
    implementation 'com.squareup.retrofit2:converter-jackson:2.1.0'

    // PhilJay MPAndroidChart
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'

    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

    //PhotoView
    implementation 'com.github.chrisbanes:PhotoView:2.1.4'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    annotationProcessor 'androidx.annotation:annotation:1.1.0'
    //Circle Image View
    implementation 'de.hdodenhof:circleimageview:3.1.0'


}

帮我解决问题, 谢谢!

【问题讨论】:

    标签: java android kotlin websocket okhttp


    【解决方案1】:

    您必须使用所有 com.squareup.okhttp3 依赖项的单一一致版本。升级到 3.12.13

        implementation "com.squareup.okhttp3:okhttp-urlconnection:3.12.13"
        implementation "com.squareup.okhttp3:okhttp-urlconnection:3.12.13"
    

    【讨论】:

      猜你喜欢
      • 2021-10-13
      • 2022-11-11
      • 2021-06-08
      • 2020-09-12
      • 2022-11-16
      • 2022-07-22
      • 2022-08-20
      • 2020-06-13
      • 2023-04-11
      相关资源
      最近更新 更多