0

I've exported a project from eclipse - but now I cannot add the support library to my project compile 'com.android.support:support-v4:21.0.0' beause the libraries that are used in this project have their own copy of the same library(but they have it in a jar file in their libs folder). Now when I added compile 'com.android.support:support-v4:21.0.0' I get this issue:

Error:Execution failed for task ':Athan:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/annotation/IntDef.class

Can someone help me to resolve this issue?

This is my app build.gradle

apply plugin: 'android'


dependencies {


    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':google-play-services_lib')
    compile project(':library_viewpager')
    compile project(':sliding_library')
    compile project(':android-support-v7-appcompat')
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:support-v4:21.0.0'
}

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    dexOptions {
        preDexLibraries = false
    }

    defaultConfig {
        multiDexEnabled true
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Darko Petkovski
  • 3,892
  • 13
  • 53
  • 117
  • just remove it. if you already have a library project using this dependency it should get picked up when you add the dependency for that library – kandroidj Apr 17 '15 at 12:02
  • possible duplicate of [Multiple dex files define Landroid/support/v4/ in android studio](http://stackoverflow.com/questions/23264223/multiple-dex-files-define-landroid-support-v4-in-android-studio) – Haresh Chhelana Apr 17 '15 at 12:05
  • check that the versions of jar are same. For eg when you import libraries then if same jar is in both libs then copy one and paste it in other. It will ask for replace option. click yes – Hulk Apr 17 '15 at 12:27
  • Out of scope, but instead of bringing google-play-service as external project provide appropriate dependency. See here http://developer.android.com/google/play-services/setup.html – peter_budo Apr 17 '15 at 12:36

1 Answers1

5

Add support jar only in library projects. No need to add it in main project and keep in mind all support library should be of same version

Tofeeq Ahmad
  • 11,935
  • 4
  • 61
  • 87
  • Thank you. Per the hint of your answer, I removed the support library in the gradle file for the project, and the problem has been solved. It was not an issue until a recent Android SDK update. – Hong Apr 14 '16 at 21:34