Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android project build Failure: Java class duplication

I am trying to build my android project. I could not understand even if the **rt.jar** which contains classes of,

 **javax.sound.*.**
 **java.awt.*.**
 **java.awt.** 

is already there in the jdk1.7/jar folder and also it can be loaded seen under IDE librarie/java but it gives me the error of saying the library classes not found. When i imported the library to the project and build it it says,

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: javax/xml/XMLConstants.class

duplication error of classes. How come this happen?

Any help will be really appreciated to overcome this issue.

Please find the build.gradle file here,

apply plugin: 'com.android.application'

android {

    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "info.androidhive.sleepApp"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        // Enabling multidex support.
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0+'
}

This is the gradle error:

 Information:Gradle tasks [:app:assembleDebug]
    :app:preBuild UP-TO-DATE
    :app:preDebugBuild UP-TO-DATE
    :app:checkDebugManifest
    :app:preReleaseBuild UP-TO-DATE
    :app:prepareComAndroidSupportAppcompatV72220Library UP-TO-DATE
    :app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
    :app:prepareComAndroidSupportRecyclerviewV72220Library UP-TO-DATE
    :app:prepareComAndroidSupportSupportV42220Library UP-TO-DATE
    :app:prepareDebugDependencies
    :app:compileDebugAidl UP-TO-DATE
    :app:compileDebugRenderscript UP-TO-DATE
    :app:generateDebugBuildConfig UP-TO-DATE
    :app:generateDebugAssets UP-TO-DATE
    :app:mergeDebugAssets UP-TO-DATE
    :app:generateDebugResValues UP-TO-DATE
    :app:generateDebugResources UP-TO-DATE
    :app:mergeDebugResources UP-TO-DATE
    :app:processDebugManifest UP-TO-DATE
    :app:processDebugResources UP-TO-DATE
    :app:generateDebugSources UP-TO-DATE
    :app:processDebugJavaRes UP-TO-DATE
    :app:compileDebugJava UP-TO-DATE
    :app:compileDebugNdk UP-TO-DATE
    :app:compileDebugSources UP-TO-DATE
    :app:collectDebugMultiDexComponents UP-TO-DATE
    :app:packageAllDebugClassesForMultiDex FAILED
    Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
    > java.util.zip.ZipException: duplicate entry: javax/xml/XMLConstants.class
    Information:BUILD FAILED
    Information:Total time: 6.793 secs
    Information:1 error
    Information:0 warnings
    Information:See complete output in console
like image 863
AshanD Avatar asked Nov 30 '25 00:11

AshanD


1 Answers

Check this question u might get and idea about java swing in android platform.

how to import javax.swing in android studio

like image 153
nayakPan Avatar answered Dec 02 '25 12:12

nayakPan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!