您的位置:首页 > 移动开发

DexIndexOverflowException issue after updating to latest appcompat and support library

2016-04-27 10:22 429 查看
今天遇到这个错误:
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: