Asked  7 Months ago    Answers:  5   Viewed   34 times

I am not sure what this error means.

Execution failed for task ':excelSior:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/util/TimeUtils.class

I am currently using android-support-v4.jar for my libraries

dependencies {
    compile project(':addThisSDK')
    compile project(':centeredContentButton')
    compile project(':googleplayservices_lib')
    compile files('libs/adxtag2.4.6.jar')
    compile files('libs/android-support-v4.jar')
    compile files('libs/aws-android-sdk-1.7.1.1-debug.jar')
    compile files('libs/commons-lang-2.6.jar')
    compile files('libs/crittercism_v4_4_0_sdkonly.jar')
    compile files('libs/dd-plist.jar')
    compile files('libs/FiksuAndroidSDK_4.1.1.jar')
    compile files('libs/iqengines-sdk-barcode.jar')
    compile files('libs/irEventTracker-1.2.jar')
    compile files('libs/jolt-core-0.0.7.jar')
    compile files('libs/json-utils-0.0.7.jar')
    compile files('libs/jsoup-1.7.2.jar')
    compile files('libs/kooaba-api-v4-java.jar')
    compile 'com.android.support:multidex:1.0.0'
}

Error does not show up during gradle sync. Just when I try to run the application

What could be the problem?

 Answers

17

You need to check that you have inserted v4 library and compile library? You must not repeat library in your app or your dependence program.

delete the repeat library so that just one V4 remains.

in your app dir build.gradle file add this command:

android{


    configurations {
        all*.exclude group: 'com.android.support', module: 'support-v4'
        all*.exclude group: 'com.android.support', module: 'support-annotations'
    }

}

it works for me! You can try it!

Tuesday, June 1, 2021
 
brombeer
answered 7 Months ago
78

Make sure you have the latest build toolds and sdk from the SDK manager. I have converted those jars to Gradle dependencies.

build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' } // <-- added for ksoap
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3' // <-- updated
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' } // <-- added for ksoap
    }
}

app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1" // <-- updated

    defaultConfig {
        applicationId "com.appname.android"
        minSdkVersion 8
        targetSdkVersion 22  // <-- updated
        // multiDexEnabled true  // <-- you do not need this
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.google.code.ksoap2-android:ksoap2-android:3.4.0'
    // compile files('libs/ksoap2-android-assembly-3.1.0-jar-with-dependencies.jar') // <-- avoid using jars
    compile 'com.google.zxing:core:3.2.0'
    // provided files('libs/zxing-core.jar') // <-- avoid using jars
}
Wednesday, June 2, 2021
 
Axalix
answered 7 Months ago
30

You forgot to add design support library. Just add this dependencies in your gradle app file:

implementation 'com.android.support:design:26.0.+'

Design Support Library

The Design package provides APIs to support adding material design components and patterns to your apps.

The Design Support library adds support for various material design components and patterns for app developers to build upon, such as navigation drawers, floating action buttons (FAB), snackbars, and TabLayout.

Or AndroidX dependency:

implementation "com.google.android.material:material:1.0.0"
Tuesday, July 6, 2021
 
Alix
answered 5 Months ago
59

As I workaround my above problem and find a way to overcome it. Main reason for packageAllDebugClassesForMultiDex error is the same you find in all other posts in Stackoverflow i.e. you must have some class files which are available more than once in project. In my case I have so many modules in above project as Facebook , google pay services and sliding menu etc.. . All these module have there own copy of v4.support jar file. What I did was delete all v4.support files from all these libraries libs folder. Then Add dependency to v4.support lib from my sdks i.e. com.android.support libs from Android Studio project Structure. For This..

  • 1* GO to File>Project Structure.
  • 2* Select each one of these modules one by one.

  • 3* In the last tab named Dependency , Remove compile fileTree(dir: 'libs', include: '*.jar') if you had only v4.support lib (or the probleomatic one)in libs folder of that module.

  • 4* Add v4.support lib by clicking + then add libraries and select v4.support libs from your sdks.

Its done. Clean the project and build it again.packageAllDebugClassesForMultiDex problem has gone.

As for transitive dependency , if you know the exact dependency which cause the Duplicate file in dex error while building the project, you can exclude it as belo

 compile(project(':..:..:..:..:..:..:android_libraries:walletsdkandroidmodule')) {
        exclude group: 'com.google.code.gson'
    }

If you want any transitive dependency in any module, eg.

compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
        transitive = true
    }
Friday, July 30, 2021
 
lupz
answered 5 Months ago
28

I fixed your build script which should be working regarding AndroidAnnotations:

apply plugin: 'com.android.application'

ext.androidAnnotationsVersion = '3.3.2';

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

apply plugin: 'com.neenbedankt.android-apt'

dependencies {
    apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
    compile "org.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.dev.app_name"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "0.3"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

apt {
    arguments {
        androidManifestFile variant.outputs[0]?.processResources?.manifestFile
        resourcePackageName "com.dev.app_name" // the same as package in the manifest
    }
}

Update: to use with annotationProcessor instead of apt:

android {
    defaultConfig {
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["resourcePackageName": "com.dev.app_name"]
            }
        }
    }
}

And make sure you are using the latest version of AndroidAnnotations.

Tuesday, November 9, 2021
 
Naughty.Coder
answered 4 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share