0
votes

I have imported project from Eclipse to Android studio. It builds successfully, but when I try to execute the project in android studio I am getting following exception .

UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)

Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 2

And here is my Build.gradle file.

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.heal4me_app"
        minSdkVersion 11
        targetSdkVersion 19
    }

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

dependencies {
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile files('libs/android-support-v13.jar')

   }

I have tried all the posted solution for the above problem, which is available on stackoverflow. But I couldn't find any right answer for this problem.

2

2 Answers

0
votes

I had the same issue after adding the library com.amazonaws:aws-java-sdk:1.8.0 to my gradle dependencies. After removing the dependencie, everything seems to be fine. I don't know why, if I find a solution I report it.

0
votes

After the many efforts I have to finally do the hard work to migrate from eclipse to android studio.

I have copied all the java classes and xml file one by one to the android studio. And finally I am done. I think this is not the good solution but I have to do this compulsorily to resolve above error.

I have read so many blogs and stackoverflow questions regarding this issue. but unfortunately that didn't help me, that's why I have to come up with this hard work.