简体   繁体   English

任务“:app:mergeDebugJavaResource”执行失败

[英]Execution failed for task ':app:mergeDebugJavaResource'

I tried to add the 'net.sourceforge.htmlunit:htmlunit:2.56.0' dependency and as soon as i added the dependency in build.gradle file and build it, it showed me following error when compiled:我尝试添加'net.sourceforge.htmlunit:htmlunit:2.56.0'依赖项,一旦我在 build.gradle 文件中添加依赖项并构建它,它在编译时显示以下错误:

Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
   > 2 files found with path 'mozilla/public-suffix-list.txt' from inputs:
      - C:\Users\sahil\.gradle\caches\transforms-3\8fe5538c146366c9e0e4211b031fbd93\transformed\jetified-firebase-crashlytics-buildtools-2.8.0.jar
      - C:\Users\sahil\.gradle\caches\transforms-3\b85d4a7c5a7eed5878de800858d05603\transformed\jetified-httpclient-4.5.13.jar
     Adding a packagingOptions block may help, please refer to
     https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
     for more information

My build.gradle file before adding the dependency:在添加依赖项之前,我的 build.gradle 文件:

plugins {
    id 'com.android.application'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.covid19"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildFeatures {
        viewBinding true
    }
    packagingOptions {

        exclude 'META-INF/DEPENDENCIES'

    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
    implementation 'androidx.navigation:navigation-fragment:2.3.5'
    implementation 'androidx.navigation:navigation-ui:2.3.5'
    implementation 'com.google.firebase:firebase-crashlytics-buildtools:2.8.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'com.github.KwabenBerko:News-API-Java:1.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.squareup.okhttp3:okhttp:4.9.0'
    implementation 'net.sourceforge.htmlunit:htmlunit:2.56.0'
    implementation 'com.android.support:multidex:1.0.3'



    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    implementation 'com.googlecode.json-simple:json-simple:1.1'
    implementation 'com.squareup.okhttp3:okhttp:4.9.0'
    implementation 'org.apache.httpcomponents:httpcore:4.4.10'

}

Try to use another version like this 'net.sourceforge.htmlunit:htmlunit:2.54.0'尝试使用像这样的另一个版本 'net.sourceforge.htmlunit:htmlunit:2.54.0'

You can add mozilla/public-suffix-list.txt to packaging options like您可以将mozilla/public-suffix-list.txt到打包选项中,例如

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'mozilla/public-suffix-list.txt'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM