我在Android Studio中使用gradle项目时出现此问题。当我玩的时候,我有这个错误,但是当我进行清理和重建时,它没有显示任何错误。
我跑
时出错AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}
AGPBI: {"kind":"SIMPLE","text":"java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536","position":{},"original":"java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)","position":{},"original":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)","position":{},"original":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:188)","position":{},"original":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:188)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)","position":{},"original":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:230)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:230)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:199)","position":{},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:199)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.Main.main(Main.java:103)","position":{},"original":"\tat com.android.dx.command.Main.main(Main.java:103)"}
这是我的gradle文件配置。我认为错误来自这里。
buildscript {
repositories {
mavenCentral()
//maven { url 'http://dt-imac-ba-032:8082/nexus/content/repositories/legacy/' }
flatDir { dirs 'libs' }
maven {
url "https://mint.splunk.com/gradle/"
}
}
}
allprojects {
repositories {
mavenCentral()
//maven { url 'http://dt-imac-ba-032:8082/nexus/content/repositories/legacy/' }
flatDir { dirs 'libs' }
maven {
url "https://mint.splunk.com/gradle/"
}
maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':qRCodeReaderViewlib')
compile ('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
transitive = true
}
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:cardview-v7:21.0.3'
}
android {
compileSdkVersion 21
buildToolsVersion "19.1.0"
compileOptions.encoding = 'windows-1251'
lintOptions {
abortOnError false
}
signingConfigs {
// debug {
// storeFile file("../keystore/sam.keystore")
//}
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/INDEX.LIST'
}
defaultConfig {
targetSdkVersion 21
}
}
在qRCodeReaderViewlib
中apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/core.jar')
}
错误在哪里?
答案 0 :(得分:0)
据我所知,当您多次使用某些库时会发生此错误 在这种情况下,可能在“qRCodeReaderViewlib”中添加了一些应用程序库,例如supportlibrary
答案 1 :(得分:0)
如果您要进行任何更改,则需要在app level build.gradle中执行此操作,而不是在顶级根目录build.gradle中执行此操作。例如,如果您要添加任何支持库,请将其添加到您在应用中找到的build.gradle中,而不是在顶级根目录中的build.gradle中。
答案 2 :(得分:0)
请参阅此link:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}