升级到OkHttp 4后,如何解决“ com.android.builder.dexing.DexArchiveBuilderException”?

时间:2019-07-30 08:32:57

标签: android gradle kotlin okhttp

将OkHttp从3.14.2升级到4.0.1后,尝试进行调试构建时,gradle在“ transformClassesWithDexBuilderForDebug”任务上失败。

一些答案​​建议添加对1.8的兼容性,但我已经在应用程序的build.gradle中添加了它们

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.example.packagename"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
//    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.squareup.okhttp3:okhttp:4.0.1'
}

构建输出(省略“ at ...”)

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process path\to\project\app\build\intermediates\transforms\profilers-transform\debug\6.jar
Caused by: com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process path\to\project\app\build\intermediates\transforms\profilers-transform\debug\6.jar
Caused by: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process path\to\project\app\build\intermediates\transforms\profilers-transform\debug\6.jar
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process path\to\project\app\build\intermediates\transforms\profilers-transform\debug\6.jar
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Caused by: java.lang.NullPointerException

0 个答案:

没有答案