不能在Android的Studio中运行项目 [英] Cannot run project in Android Studio

查看:146
本文介绍了不能在Android的Studio中运行项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图运行我的Andr​​oid Studio中的项目,我得到了以下错误消息

When I was trying to run my project in Android Studio, I got the following error message

Execution failed for task ':CricHQ:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/19.0.1/dx -JXmx4g --dex --output 
Error Code:
2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Cannot merge new index 66514 into a non-jumbo instruction!
    at com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:108)
    at com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:25)
    at com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:71)
    at com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)
    at com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)
    at com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:48)
    at com.android.dx.merge.DexMerger.transformCode(DexMerger.java:840)
    at com.android.dx.merge.DexMerger.transformMethods(DexMerger.java:811)
    at com.android.dx.merge.DexMerger.transformClassData(DexMerger.java:783)
    at com.android.dx.merge.DexMerger.transformClassDef(DexMerger.java:680)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:540)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)

任何人都可以帮我解决这个问题?非常感谢。

Anyone can help me with this problem? Thanks a lot.

推荐答案

有一个关于Java方法,你可以在一个单一的文件DEX的数量在Android的限制,和你打的限制。不幸的是,有没有简单的解决方案吧。你的选择是:

There's a limitation in Android on the number of Java methods you can have in a single dex file, and you're hitting that limit. Unfortunately, there's no easy solution to it. Your choices are:


  • 简化您的code。如果你使用了很多库,看看你是否能削减你使用图书馆的数量。有些图书馆有很多方法在其中。

  • 甚至在你的调试版本搭配使用ProGuard。 ProGuard的将去掉未使用的方法,可以节省大量的空间。要获得ProGuard的开始,看看这些链接:

    • http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Running-ProGuard

    • 对于调试版本,你可能不希望ProGuard的混淆你的类和方法的名称 - 它将使生活更加困难。你想它只是做它的死code剥离。这个问题将有你一些指点:<一href=\"http://stackoverflow.com/questions/9651703/using-proguard-with-android-without-obfuscation\">Using Proguard的与Android不混淆

    • Simplify your code. If you're using a lot of libraries, see if you can cut back on the number of libraries you're using. Some libraries have a lot of methods in them.
    • Use ProGuard even in your debug builds. ProGuard will strip out unused methods and can save a lot of space. To get started on ProGuard, look at these links:
      • http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Running-ProGuard
      • For debug builds, you probably don't want ProGuard to obfuscate your class and method names -- it will make life much more difficult. You'd like it to just do its dead code stripping. This question will have you some pointers: Using Proguard with Android without obfuscation

      如果这些方法都不管用,有可能您的应用程序分割成多个DEX文件,并使用类加载器的技巧,使其在运行时的工作,但这是更为复杂的。

      If those approaches don't work, it's possible to split your application into multiple dex files and use classloader tricks to make it work at runtime, but that's more complicated.

      这篇关于不能在Android的Studio中运行项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆