1

Hello i get the error while trying to run my app it was an app that used to work(while it was in eclipse ) been trying to make it work in android studio after several errors now this1 hit me and cant figure out anything . Thank You for help.

EDİT No error when i build the app it comes when i try to run the app.

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:502)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_65\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED

Build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
}
apply plugin: 'android'

dependencies {
    compile "com.android.support:support-v4:23.1.1"
compile 'com.android.support:appcompat-v7:23.1.1'
compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'

    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')
    }
}
Wince
  • 129
  • 1
  • 11

2 Answers2

1

Delete the android_support_annotations.jar file, as recommended at this answer. Your problem is caused by the annotations jar being included by default in the Android support library so there are now two copies.

You could also try temporarily removing compile "com.android.support:support-v4:18.0.+" from your build.gradle and see if that makes a difference.

(The solution was to remove all but compile 'com.android.support:appcompat-v7:23.1.1' in the dependencies).

Community
  • 1
  • 1
Peter Gordon
  • 1,075
  • 1
  • 18
  • 38
0

so basicly after removing every compile part it worked when only this left

dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'

}

changed dependices to this

Wince
  • 129
  • 1
  • 11