Gradle构建完成错误

时间:2015-07-23 05:43:05

标签: android gradle

我正在尝试运行我在Android Studio中的Eclipse项目,但gradle插件给了我一个艰难的时间,首先它说不支持的Gradle版本,然后我修改了build.gradle,现在当我尝试在末尾运行它Gradle finished with 1 error,这是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

这是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')
}
}

这是消息日志:

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)

感谢您的帮助

2 个答案:

答案 0 :(得分:5)

感谢您的回复。我最后通过删除这一行来解决问题:

compile fileTree(dir: 'libs', include: '*.jar')

答案 1 :(得分:0)

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

--->这个代码段是在您的Top build.gradle还是模块build.gradle中?

无论如何尝试将此部分分离到Top build.gradle,它是具有 - >“(项目:项目名称)”作为提示的build.gradle。