I have a big Android project where I got Unable to execute method identifier dex: ID not in [0, 0xffff]: 65536 error; I believe that some of you guys have definitely experienced this problem before. This is a bug due to too many methods specified in the application.
I searched various sources on the Internet and found this might be the best solution.
And I did the following:
- Added
multiDexEnabled = true to the defaultConfig build.gradle block. The following dependency is added:
dependencies { compile 'com.android.support:multidex:1.0.0' }
In my App class, the following code is overridden.
@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); }
Now the error has disappeared, but I have a new problem. When I run the application, the compiler takes more than 3 minutes to compile and run the application, and finally gives me this error:
UNEXPECTED TOP-LEVEL ERROR: java.lang.OutOfMemoryError: Java heap space
I understand that this error occurs due to heavy memory usage, but I don’t know how to solve it. I am using Android Studio 1.0.2 and Android API 21.
Thanks!
EDIT
I already checked How to fix "OutOfMemoryError: java heap space" when compiling a MonoDroid application in MonoDevelop , but this does not explain the cause of the problem, and moreover, I do not use Xamarin Studio.
EDIT2
The exact symptom is as follows:
When I compile the code, the gradle console shows me hundreds of warnings that say: “Ignoring the InnerClasses attribute for an anonymous inner class” (that some other answers from stackoverflow indicate that these are not serious warnings), and then only shows a blinking cursor for time, and after about one minute it gives me an error.
source share