问题
I have and android project. When i import it to eclipse . it works fine . But when i imported it to Android studio its giving :-
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
error while building . Is it even possible for a project to behave diffrently in eclipse and Android Studio . In both case (Yes / No) , how do i resolve it
I have checked my build.gradle file for dependencies . All the dependencies are same as what i am using in eclipse.
回答1:
Android has a pre-defined upper limit of Methods of 65536
.
The most common cause of this is using the full google play services library, instead of just the subset you need, eg design, cardview, maps etc.
If this is not the case, then use the multidex
library, which enables a bigger limit.
See here:
http://developer.android.com/tools/support-library/features.html#multidex
Basically just this in gradle:
com.android.support:multidex:1.0.0
回答2:
For ANDROID STUDIO... Enable Instant Run
In File->Preferences->Build, Execution, Deployment->Instant Run-> Check Enable Instant run for hot swap...
Hope it helps
回答3:
My problem was resolved by adding "multiDexEnabled true" as following in Module build.gradle.
android {
...
defaultConfig {
...
multiDexEnabled true
Update
With the above code, I was able to build and run on debug devices (below 'marshmallow' version), but on 'marshmallow' devices, I found the following error.
:6: error: package android.support.multidex does not exist import android.support.multidex.MultiDexApplication;
To resolve I have to use following in 'module' build.gradle of project.
compile 'com.android.support:multidex:1.0.1'
来源:https://stackoverflow.com/questions/36912079/com-android-dex-dexindexoverflowexception-method-id-not-in-0-0xffff-65536-i