且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android 4 上的 Android Studio NoClassDefFoundError

更新时间:2023-09-19 23:36:40

我没有完全实现 MultiDex 支持,所以我的一些类不在正确的 dex 文件中.要修复它,您必须做的不仅仅是在 defaultConfig 块中设置 multiDexEnabled = true.您还必须:

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:

  1. 在依赖项中包含 compile 'com.android.support:multidex:1.0.1'
  2. 让您的应用程序类扩展 MultiDexApplication 而不仅仅是 Application.或者,您可以在应用程序的 attachBaseContext() 中调用 MultiDex.install().
  1. Include compile 'com.android.support:multidex:1.0.1' in your dependencies
  2. Have your Application class extend MultiDexApplication instead of just Application. Alternatively, you can call MultiDex.install() in attachBaseContext() of your application.

https://developer.android.com/tools/building/multidex.html更多详情.