我正在尝试调试我的Android应用程序,但我从gradlew assembleDebug中得到以下错误:
AGPBI: {"kind":"simple","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","sources":[{}]}
AGPBI: {"kind":"simple","text":"com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/plus/model/people/Person$AgeRange;","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.dexer.Main.run(Main.java:246)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.dexer.Main.main(Main.java:215)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.Main.main(Main.java:106)","sources":[{}]}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:Program FilesJavajdk1.8.0_11binjava.exe'' finished with non-zero exit value 2
我看了过去类似的问题,但无法找到解决方案。我认为这与我的gradle文件有关,因为我刚刚添加了一些Google API的东西。
构建。Gradle for project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
构建。Gradle for module:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.zarwanhashem.ideatrackr"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
}
自从我上次成功调试后,唯一添加到这些文件中的东西是Google的东西。我尝试了clean build, delete .gradle和delete .idea。
编辑:下面是我的libs文件夹中的jar,以防有些冲突:gdata-client-1.0.jar
gdata-client-meta-1.0.jar
gdata-core-1.0.jar
gdata-spreadsheet-3.0.jar
gdata-spreadsheet-meta-3.0.jar
google-play-services.jar
gson-2.2.4.jar
guava-18.0.jar
编辑2:按照下面注释中的说明操作后,错误信息变为如下:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/x.class
我浏览了我的库,但只能在google play jar中找到gms目录,所以我不知道它与什么相冲突。
我想你从eclipse迁移到AS你的文件夹库中仍然有
android-support-v4.jar ,>
删除它和它应该工作