我刚刚在我的应用程序中遇到了一个尴尬的错误。
在我的Nexus 5/7上,运行Android 5.0.1/5.0.2,一切正常。 但是,如果我尝试在早期版本的设备上运行完全相同的代码(已测试4.4.4和4.3),我会收到以下错误:
03-13 13:49:41.140 21714-21714/? E/dalvikvm﹕ Could not find class 'com.default.package.application.model.Appcomponent', referenced from method com.default.package.application.controller.DatabaseHandler.getScreenComponents
03-13 13:49:41.140 21714-21714/? E/dalvikvm﹕ Could not find class 'android.support.v7.app.ActionBarActivityDelegate$1', referenced from method android.support.v7.app.ActionBarActivityDelegate.<init>
03-13 13:49:41.140 21714-21714/? E/dalvikvm﹕ Could not find class 'android.support.v7.app.ActionBarActivityDelegateHC', referenced from method android.support.v7.app.ActionBarActivityDelegate.createDelegate
03-13 13:49:41.140 21714-21714/? E/dalvikvm﹕ Could not find class 'android.support.v7.app.ActionBarActivityDelegateBase', referenced from method android.support.v7.app.ActionBarActivityDelegate.createDelegate
03-13 13:49:41.150 21714-21714/? E/dalvikvm﹕ Could not find class 'android.support.v7.app.ActionBarActivityDelegate$ActionBarDrawableToggleImpl', referenced from method android.support.v7.app.ActionBarActivityDelegate.getDrawerToggleDelegate
03-13 13:49:41.150 21714-21714/? E/dalvikvm﹕ Could not find class 'android.support.v7.internal.view.SupportMenuInflater', referenced from method android.support.v7.app.ActionBarActivityDelegate.getMenuInflater
03-13 13:49:41.150 21714-21714/? E/dalvikvm﹕ Could not find class 'android.support.v7.app.ActionBarActivityDelegate$ActionBarDrawableToggleImpl', referenced from method android.support.v7.app.ActionBarActivityDelegate.getV7DrawerToggleDelegate
03-13 13:49:41.150 21714-21714/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.default.package, PID: 21714
java.lang.NoClassDefFoundError: android.support.v7.app.ActionBarActivityDelegateHC
我已经尝试将support.v7库添加为jar文件,但没有任何改变。 但是既然它可以在Lollipop设备上运行,这就没有意义了。
可能存在一些与Dalvik/Art更改有关的问题吗? 或者可能是因为我不得不使用com.android.support:multidex:1.0.0,因为这是一个相当大的应用程序。
更新: 我尝试删除一些依赖项以使方法数少于65k的限制。之后,该应用在4.4.4和4.3设备上运行。 启用multidex支持所做的全部工作只是设置
multiDexEnabled true
在defaultConfig部分中添加。compile 'com.android.support:multidex:1.0.0'
在我的 build.gradle 的依赖项部分下面。
不知道为什么这会导致在旧的 Android 版本上出现这些问题?
com.default.package.application.model.appcomponent
是从哪里来的? - Jonas Czech