简体   繁体   中英

Gradle build finished with error

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

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

compile fileTree(dir: 'libs', include: '*.jar')
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM