com.android.dex.DexIndexOverflowException: method ID notin[0,0xffff]:65536
找了好久发现了解决办法:
This message sounds like your project is too large.
You have too many methods. There can only be 65536 methods for dex.
Since the gradle plugin 0.14.0 and the Build Tools 21.1.0 you can use the multidex support.
Just add these lines in the build.gradle
:
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Also in your Manifest
add the MultiDexApplication
class from the multidex support library to the application element
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
If you are using a own Application
class, change the parent class from Application
to MultiDexApplication
.
或者:
If your app uses extends the Application class add this code
@Override
public void attachBaseContext(Context base) {
MultiDex.install(base);
super.attachBaseContext(base);
}
转载自:http://stackoverflow.com/questions/26515378/dexindexoverflowexception-issue-after-updating-to-latest-appcompat-and-support-l