skip to Main Content

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:

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:Userssahil.gradlecachestransforms-38fe5538c146366c9e0e4211b031fbd93transformedjetified-firebase-crashlytics-buildtools-2.8.0.jar
      - C:Userssahil.gradlecachestransforms-3b85d4a7c5a7eed5878de800858d05603transformedjetified-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:

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'

}

2

Answers


  1. Try to use another version like this ‘net.sourceforge.htmlunit:htmlunit:2.54.0’

    Login or Signup to reply.
  2. You can add mozilla/public-suffix-list.txt to packaging options like

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'mozilla/public-suffix-list.txt'
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search