我的应用程序为 sdk 19 或更低版本提供 NoClassDefFoundError
。
我在我的毕业典礼上
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.idg.mail"
minSdkVersion 14
targetSdkVersion 23
multiDexEnabled = true
}
现在我试着把它改成
compileSdkVersion 19
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.idg.gatcamail"
minSdkVersion 19
targetSdkVersion 19
multiDexEnabled = true
}
我也在 app-> module settings - android - sdk
中进行了更改。
通过这些更改,我构建了项目,但它仍然在我的 android 4.4
上出现相同的错误,并且它在更高版本上运行。
该类是在我处理网络操作的代码中定义的类。
如何调试这个问题
最佳答案
我几乎可以肯定这是 multidex 问题。如果它在 sdk 21 上正常运行 - 这是 multidex 问题。
这是官方信息:Multidex
如果您使用 Application 类的自定义实现,它必须扩展 MultiDexApplication 类。还需要 gradle 标志。如果您不使用自定义应用程序类,只需添加 list 中提供的条目 - 文档中对此进行了描述。
编辑:差点忘了 - 你必须添加依赖项,这个库提供了 multidex:compile 'com.android.support:multidex:1.0.1'
关于android : NoClassDefFoundError for android 4. 4及以下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36889914/