AS更新到1.0后,得到“method ID not in [0, 0xffff]: 65536"项目错误 [英] After update of AS to 1.0, getting "method ID not in [0, 0xffff]: 65536" error in project
问题描述
我将 Android Studio 更新到最新版本,并让它修复项目"等 - 但现在我的项目无法编译,给了我
I updated Android Studio to the latest version, and let it "fix the project" and the like - but now my project does not compile, gives me
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\VGA\AndroidStudio\sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --output D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\dex\debug --input-list=D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
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:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
然而,这并不能通过多索引解决,因为当我添加这个时:
However, this isn't resolved by just multidexing, because when I added this:
defaultConfig {
...
multiDexEnabled = true
}
这种情况发生
D:\VGA\AndroidStudio\sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --multi-dex --main-dex-list D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\multi-dex\debug\maindexlist.txt --output D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\dex\debug --input-list=D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\tmp\dex\debug\inputList.txt
错误代码:3输出:
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.cf.code.ConcreteMethod.makeSourcePosistion(ConcreteMethod.java:254)
at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:306)
at com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:612)
at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:367)
at com.android.dx.cf.code.Simulator.simulate(Simulator.java:94)
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:787)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:742)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:349)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:280)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
at com.android.dx.command.dexer.Main.processClass(Main.java:729)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:82)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:332)
at com.android.dx.command.dexer.Main.run(Main.java:243)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
我尝试将构建工具更改为最新的
I tried changing the build tools to latest
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
因为默认情况下它更改为 20.0.0,这似乎将 SDK 用于 4.4W,但这并没有解决我的问题.
Because by default it changed to 20.0.0 which seemed to use the SDK for 4.4W, but this didn't fix my problem.
有谁知道这里有什么问题吗?
Does anyone know what could be wrong here?
更改构建工具或编译 SDK 均未解决问题.
Changing the build tools or the compile SDK did not fix the problem.
将应用程序变成多 dex 项目并添加以下内容
Turning the app into a multi-dex project and also adding the following
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
...
multiDexEnabled true
}
...
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
修复了构建过程,但这似乎仍然只是一种处理",而不是解决问题.
Fixed the build process, however this still seems to be just a "treatment" but not a fix to the problem.
我不确定这是否相关,但这是我的依赖列表:
I am not sure if this is related, but this is my dependency list:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.7.1'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile 'com.madgag.spongycastle:prov:1.51.0.0'
compile 'com.madgag.spongycastle:pkix:1.51.0.0'
compile 'com.google.code.gson:gson:2.3'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
compile('com.googlecode.json-simple:json-simple:1.1.1') {
exclude module: 'junit'
}
compile 'com.google.android.gms:play-services:6.5.87'
}
此后唯一的新依赖项是最后一行,我根据 https://developer 添加.android.com/google/gcm/client.html 所以我认为这不是问题的根源.
The only new dependency since then has been the last line, which I added as per https://developer.android.com/google/gcm/client.html so I don't think that is the source of the problem.
是的,这就是问题的根源.由于我需要 Google Cloud Messaging
,我根据 http://developer.android.com/google/play-services/setup.html#split:
Yes, it was the source of the problem. As I needed Google Cloud Messaging
, I replaced that dependency with the base as per http://developer.android.com/google/play-services/setup.html#split :
compile 'com.google.android.gms:play-services-base:6.5.87'
它解决了这个问题.谢谢你的帮助.
And it fixed the problem. Thank you for the help.
从播放服务 7.0.0 开始,GCM 处于
As of play services 7.0.0, the GCM is in
compile 'com.google.android.gms:play-services-gcm:7.0.0'
播放服务更新至 7.3.0.请在此处查看最新版本:http://developer.android.com/google/play-services/setup.html#split
Play Services updated to 7.3.0. Please keep check of the latest version here: http://developer.android.com/google/play-services/setup.html#split
推荐答案
该错误意味着您已达到应用中的最大方法数.这确实包括您用于项目的所有库.
The error means you have reached maximum method count in your app. That does include any libraries that you use for your project.
有两种方法可以解决这个问题:
There are two ways to tackle the issue:
- 删除您并不真正需要的任何第三方库.如果您使用可能对方法计数有很大贡献的 google play 服务.幸运的是,从最新的播放服务发布开始,它可以只包含部分 框架.
- 为您的应用程序使用 多 dex 设置.
这篇关于AS更新到1.0后,得到“method ID not in [0, 0xffff]: 65536"项目错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!