2

I am trying to run a previous project I had in Eclipse in Android Studio, but the gradle plugin is giving me a hard time, first it said unsupported version of Gradle, then I modified the build.gradle, and now when I try to run it at the ends says Gradle finished with 1 error, this is the gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-   all.zip

this is the build.gradle:

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

apply plugin: 'android'

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

android {
compileSdkVersion 19
buildToolsVersion "22.0.1"

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

    instrumentTest.setRoot('tests')

    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}
}

This is the the message log:

Error:Execution failed for task ':dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run     command:
C:\Users\jake\AppData\Local\Android\sdk\build-tools\22.0.1\dx.bat --dex --   no-optimize --output    C:\Users\jake\workspace\android\Staff\build\intermediates\dex\debug --input-        list=C:\Users\jake\workspace\android\Staff\build\intermediates\tmp\dex\debug\inp    utList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define     Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$Accessib    ilityServiceInfoVersionImpl;
    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)

Thanks for your help

Jhonycage
  • 759
  • 3
  • 16
  • 36
  • @AnirudhSharma sorry I update the post with the error log – Jhonycage Jul 23 '15 at 05:51
  • Could you provide the dependencies you're using ? It seems to me that some of your dependencies are also having `support-v4` and the main project also using `support-v4` ? In the meantime, try looking at this smiliar [question](http://stackoverflow.com/questions/20989317/multiple-dex-files-define-landroid-support-v4-accessibilityservice-accessibility) – Ye Lin Aung Jul 23 '15 at 06:20

2 Answers2

5

Thanks for replies. I ended up solving the problem by deleting this line:

compile fileTree(dir: 'libs', include: '*.jar')
Dan Beaulieu
  • 19,406
  • 19
  • 101
  • 135
Jhonycage
  • 759
  • 3
  • 16
  • 36
0
buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0'
}
}

---> Is this snippet inside your Top build.gradle or the module build.gradle?

Anyways try to separate this part to the Top build.gradle which is the build.gradle that has the -->"(Project: Project Name)" as hint.

mangu23
  • 884
  • 9
  • 13