Конфликт зависимости в Gradle - PullRequest
0 голосов
/ 03 февраля 2020

Я получаю эту конфликтную ошибку при модернизации:

java .lang.RuntimeException: дубликат класса com.google.gson.DefaultDateTypeAdapter обнаружен в модулях gson-2.8.5.jar (com .google.code.gson: gson: 2.8.5) и pubnub-gson-4.19.0-all.jar (pubnub-gson-4.19.0-all.jar)

Вот мой gradle-файл со всеми зависимостями:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
//    buildToolsVersion '27.0.3'
//    useLibrary 'org.apache.http.legacy'
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }


    defaultConfig {
        applicationId "com.chaufferapplication"
        minSdkVersion 19
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 38
        versionName "4.6.6.0"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    lintOptions {
        // Returns whether lint should be quiet (for example, not write informational messages such as paths to report files written)
        quiet true

        // Whether lint should set the exit code of the process if errors are found
        abortOnError false

        // Returns whether lint will only check for errors (ignoring warnings)
        ignoreWarnings true

        // Returns whether lint should check for fatal errors during release builds. Default is true.
        // If issues with severity "fatal" are found, the release build is aborted.
        checkReleaseBuilds false
    }
}

dependencies {
    implementation files('libs/json-20140107.jar')
    implementation files('libs/mobiprobe7.0.jar')
    implementation files('libs/pubnub-gson-4.19.0-all.jar'){
        configurations {
            compile.exclude module: 'okhttp3'
        }
    }
    annotationProcessor files('libs/pubnub-gson-4.19.0-all.jar'){
        configurations {
            compile.exclude module: 'okhttp3'
        }
    }
    implementation files('libs/test.jar')
    implementation files('libs/WebSocket.jar')
    implementation 'com.mikhaellopez:circularimageview:3.2.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'com.google.android.gms:play-services-places:17.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-analytics:17.0.0'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation "se.emilsjolander:stickylistheaders:2.7.0"
    implementation 'me.grantland:autofittextview:0.2.+'
    implementation 'org.droidparts:droidparts:2.9.6'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'me.tankery.lib:circularSeekBar:1.1.7'
    implementation 'ch.acra:acra:4.9.0'
    implementation 'com.google.maps.android:android-maps-utils:0.5+'
    implementation 'androidx.multidex:multidex:2.0.0'
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.2.0'
    implementation 'me.biubiubiu.justifytext:library:1.1'
    implementation 'org.jsoup:jsoup:1.11.3'
    implementation 'com.google.firebase:firebase-core:17.0.1'
    implementation 'com.google.firebase:firebase-messaging:19.0.1'
    implementation 'com.google.firebase:firebase-crash:16.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    //Retrofit
    implementation "com.squareup.retrofit2:retrofit:2.6.1"
   // implementation "com.squareup.retrofit2:converter-gson:2.6.1"
    implementation "com.squareup.retrofit2:converter-scalars:2.6.1"

}
apply plugin: 'com.google.gms.google-services'

Во время работы приложения возникает ошибка с модификацией и конфликтом PubNub. У кого-нибудь есть решение для этого? Я попытался исключить okhttp3, но все равно он не работает и выдает ошибку. Модификация - это зависимость, а pubnub - это файл jar, и оба имеют okhttp3 в качестве общего модуля и конфликтуют из-за наличия одного и того же модуля

Ответы [ 3 ]

0 голосов
/ 03 февраля 2020

Привет, ты можешь попробовать что-то, что может помочь тебе

implementation ('com.squareup.retrofit2:retrofit:2.6.1') {
        exclude module: 'okhttp'
}
0 голосов
/ 03 февраля 2020

Вы пытались добавить стратегию принудительного разрешения в свой build.gradle?

configurations.all {
    resolutionStrategy.force 'com.squareup.okhttp3:okhttp:4.3.1'
}

Подставляя нужную версию библиотеки okhttp.

0 голосов
/ 03 февраля 2020

добавить это в implementation("com.squareup.okhttp3:okhttp:4.3.1") файл app.gradle и синхронизировать c проект

...