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

NoClassDefFoundError with Android Studio on Android 4

2015-12-10 17:20 483 查看
I was incompletely implementing MultiDex support, so some of my classes weren’t in the proper dex file. To fix it, you have to do more than just set multiDexEnabled = true in your defaultConfig block. You also have to:

Include compile ‘com.android.support:multidex:1.0.0’ in your dependencies

Have your Application class extend MultiDexApplication instead of just Application. Alternatively, you can call MultiDex.install() in attachBaseContext() of your application.

See https://developer.android.com/tools/building/multidex.html for more details.

Minimal MultiDex capable application. To use the legacy multidex library there is 3 possibility:

Declare this class as the application in your AndroidManifest.xml.
Have your Application extends this class.
Have your Application override attachBaseContext starting with
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: