有一个关于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的开始,看看这些链接:
- 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.