下面NoClassDefFoundError的SDK 21NoClassDefFoundError、SDK

由网友(爱里行乞)分享简介:我刚刚经历在我的应用程序一个尴尬的问题。I just experienced an awkward bug in my App.在我的Nexus 5/7,运行的是Android 5.0.1 / 5.0.2,一切工作就好了。但是,如果我试图与早期版本的设备上运行完全相同的code(测试4.4.4和4.3)我收到以下...

我刚刚经历在我的应用程序一个尴尬的问题。

I just experienced an awkward bug in my App.

在我的Nexus 5/7,运行的是Android 5.0.1 / 5.0.2,一切工作就好了。 但是,如果我试图与早期版本的设备上运行完全相同的code(测试4.4.4和4.3)我收到以下错误:

On my Nexus 5/7, running android 5.0.1/5.0.2, everything works just fine. However if i try running the exact same code on a device with an earlier version (tested 4.4.4 and 4.3) I get the following error:

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库罐子,但都没有区别。 但是,因为它适用于棒棒糖设备,这个就没有意义呢。

I've already tried adding the support.v7 library as jar, but makes no difference. But since it works on Lollipop devices this wouldn't make sense anyway.

这可能是因为有关于在Dalvik /艺术变革的一些问题? 或者这个事实,我不得不使用com.android.support:multidex:1.0.0,因为它是一个相当大的应用程序。

Could it be that there's some issue concerning the Dalvik/Art change? Or maybe the fact that I had to use com.android.support:multidex:1.0.0 since it's a rather large app.

更新:我试着删除一些依赖下的65K方法的限制来获得。在此之后,应用程序运行在4.4.4和4.3设备。 我所做的启用multidex支持是设置

Update: I tried removing some dependencies to get under the 65k method limit. After that the app ran on 4.4.4 and 4.3 devices. All I did for enabling multidex support was setting

multiDexEnabled true

在defaultConfig部分并添加

in the defaultConfig section and adding

compile 'com.android.support:multidex:1.0.0'

下面我build.gradle的依赖部分。

below in the dependencies section of my build.gradle.

任何想法,为什么这会导致在旧的Andr​​oid版本的这些问题?

Any idea why this causes these issues on the older android versions?

推荐答案

我加入这我的应用程序类解决了这个问题。

I resolved the issue by adding this to my Application Class.

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

好像是neccessary为Android之前的版本5。

Seems to be neccessary for android versions prior 5.

阅读全文

相关推荐

最新文章