首页 > 解决方案 > 在进行发布构建时出现错误:程序类型已存在:okhttp3.Call$Factory

问题描述

当我创建发布build时,我收到了如下错误:

 Program type already present: okhttp3.Call$Factory

如果我排除 okhttp 库,例如:

configurations {
    all*.exclude group: 'xmlpull', module: 'xmlpull'
    all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}

它给出了一个错误,如:

 Library class android.content.res.XmlResourceParser implements program class org.xmlpull.v1.XmlPullParser

我的 Gradle 依赖项是:

apply plugin: 'com.android.application'
    
    android {
        signingConfigs {
            release {
            storeFile file('D:\\Paytel Project\\paytel project signed key\\paytel_b2b_key.jks')
                storePassword 'paytel@123'
                keyAlias 'key0'
                keyPassword 'paytel@123'
            }
        }
        compileSdkVersion 30
        defaultConfig {
            applicationId "com.paytel.mobilerecharge"
            minSdkVersion 21
            targetSdkVersion 30
            versionCode 2
            versionName "1.2"
            multiDexEnabled true
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            dataBinding {
                enabled = true
            }
            ndk {
                moduleName "serial_port"
            }
    //        resConfigs "en", "fr"
        }
        buildTypes {
            release {
                signingConfig signingConfigs.release
                minifyEnabled true
                debuggable true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
            debug {
                signingConfig signingConfigs.release
                debuggable true
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        dexOptions {
            incremental true
            javaMaxHeapSize "4g"
        }
        lintOptions {
            abortOnError false
            checkReleaseBuilds true
        }
        repositories {
            maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
            maven { url 'https://jitpack.io' }
        }
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    configurations {
    //    all*.exclude group: 'xmlpull', module: 'xmlpull'
    //    all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp'
    }
    
    dependencies {
        implementation 'com.github.bumptech.glide:glide:4.12.0'
    //    implementation project(path: ':mosambeelib_v_aar_1.0.0.101')
        implementation project(path: ':mosambeelib_v_1.1.0.0007.01')
        androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        implementation files('libs/simple-xml-2.7.1.jar')
        implementation group: 'xml-security', name: 'xmlsec', version: '1.3.0'
    //    implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
        implementation platform('com.google.firebase:firebase-bom:26.4.0')
        implementation 'com.google.firebase:firebase-analytics'
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
        implementation 'com.google.android.material:material:1.0.0'
        implementation 'org.jsoup:jsoup:1.8.2'
        implementation 'androidx.legacy:legacy-support-v13:1.0.0'
        implementation 'androidx.multidex:multidex:2.0.1'
        implementation 'com.google.firebase:firebase-auth:20.0.0'
        implementation 'com.google.firebase:firebase-messaging:21.0.0'
        implementation 'androidx.cardview:cardview:1.0.0'
    //    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
        implementation 'org.greenrobot:eventbus:3.0.0'
        implementation 'com.github.ekodevelops:eko-gateway-android-sdk:1.0.0'
        implementation 'com.intuit.sdp:sdp-android:1.0.6'
        implementation 'com.intuit.ssp:ssp-android:1.0.6'
    //    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
    
        implementation 'com.squareup.retrofit2:retrofit:2.8.2'
        implementation 'com.squareup.retrofit2:converter-gson:2.8.2'
        implementation 'com.squareup.okhttp3:logging-interceptor:3.14.9'
        implementation 'com.google.android.play:core:1.8.3'
    
        testImplementation 'junit:junit:4.12'
    }
    
    apply plugin: 'com.google.gms.google-services'

标签: androidandroid-gradle-plugindependencies

解决方案


推荐阅读