导入支持-v4-22.0.0时,Gradle构建失败

时间:2015-03-18 06:09:04

标签: android cordova phonegap-plugins android-gradle

我正在使用phonegap& amp ;;我添加了一个jar文件:  com.android.support:support-v4:22.0.0

但是当我运行'app'时,gradle显示失败错误:

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava
:app:preDexDebug
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/NotificationCompatHoneycomb;
    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.7.0_75\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 14.849 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

我的app.iml:

<orderEntry type="jdk" jdkName="Android API 14 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="cordova-2.7.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="java_websocket" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
<orderEntry type="library" exported="" name="google-play-services" level="project" />

我的build.gradle:

dependencies {
    compile files('libs/cordova-2.7.0.jar')
    compile files('libs/google-play-services.jar')
    compile files('libs/java_websocket.jar')
    compile 'com.android.support:support-v4:22.0.0'
}

当我删除support-v4时,我的项目运行正常。

请帮帮我。

2 个答案:

答案 0 :(得分:0)

删除该行('com.android.support:support-v4:22.0.0') 从      依赖{     编译文件('libs / cordova-2.7.0.jar')     编译文件('libs / google-play-services.jar')     编译文件('libs / java_websocket.jar')     编译'com.android.support:support-v4:22.0.0' }

答案 1 :(得分:0)

你必须编写compile&#39; com.android.support:support-v4:22.0.0&#39;进入另一个build.gradle文件(在app文件夹内)的依赖项,而不是你使用的build.gradle(在gradle文件夹中)。是的,有两个文件具有相同的名称但在不同的文件夹中。