2017-10-06 57 views
0

这个崩溃只出现在三星与4.4.2 SDK版本,并在根模式(Crashlytics的信息):安卓:致命异常:java.lang.NoClassDefFoundError(4.4.2三星)

Fatal Exception: java.lang.NoClassDefFoundError: android/graphics/drawable/Icon 
     at java.lang.Class.getDeclaredMethods(Class.java) 
     at java.lang.Class.getDeclaredMethods(Class.java:656) 
     at android.view.ViewDebug.getExportedPropertyMethods(ViewDebug.java:960) 
     at android.view.ViewDebug.exportMethods(ViewDebug.java:1047) 
     at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:997) 
     at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:983) 
     at android.view.ViewDebug.dumpView(ViewDebug.java:900) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:870) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dump(ViewDebug.java:793) 
     at android.view.ViewDebug.dispatchCommand(ViewDebug.java:416) 
     at android.view.ViewRootImpl$W.executeCommand(ViewRootImpl.java:6258) 
     at android.view.IWindow$Stub.onTransact(IWindow.java:65) 
     at android.os.Binder.execTransact(Binder.java:404) 
     at dalvik.system.NativeStart.run(NativeStart.java) 
Caused by java.lang.ClassNotFoundException: Didn't find class "android.graphics.drawable.Icon" on path: DexPathList[[zip file "/data/app/com.xxx-1.apk", zip file "/data/data/com.xxx/code_cache/secondary-dexes/com.xxx-1.apk.classes2.zip"],nativeLibraryDirectories=[/data/app-lib/com.xxx-1, /vendor/lib, /system/lib]] 
     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:497) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:457) 
     at java.lang.Class.getDeclaredMethods(Class.java) 
     at java.lang.Class.getDeclaredMethods(Class.java:656) 
     at android.view.ViewDebug.getExportedPropertyMethods(ViewDebug.java:960) 
     at android.view.ViewDebug.exportMethods(ViewDebug.java:1047) 
     at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:997) 
     at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:983) 
     at android.view.ViewDebug.dumpView(ViewDebug.java:900) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:870) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867) 
     at android.view.ViewDebug.dump(ViewDebug.java:793) 
     at android.view.ViewDebug.dispatchCommand(ViewDebug.java:416) 
     at android.view.ViewRootImpl$W.executeCommand(ViewRootImpl.java:6258) 
     at android.view.IWindow$Stub.onTransact(IWindow.java:65) 
     at android.os.Binder.execTransact(Binder.java:404) 
     at dalvik.system.NativeStart.run(NativeStart.java) 

我可以不明白为什么。我谟正确地塞米松与概念配置:

在摇篮文件:

defaultConfig { 

    minSdkVersion 19 // Min SDK supported by this app (= KITKAT) 
    targetSdkVersion 26 // SDK dedicated for this app 

    // Enabling multidex support. 
    multiDexEnabled true 

    ... 

dependencies { 
    implementation fileTree(include: ['*.jar'], dir: 'libs') 

    // https://developer.android.com/studio/build/multidex.html 
    implementation 'com.android.support:multidex:1.0.2' 

    ... 

和我的应用程序扩展MultiDexApp:

public class MyApplication extends MultiDexApplication { ... 

有你有关于这个崩溃的一些解释吗?

非常感谢你们

+1

(不是解决方案,个人观点)如果在单个设备上发生过一次单一崩溃事件,而您无法将问题跟踪到代码中的根源,只是忽略它。你很可能不会修复它 – Zoe

+1

你添加了MultiDex.install(this);在MyApplication的oncreate()中? –

+0

@SudheeshR当然是因为我扩展了MultiDexApplication类 – anthony

回答

1

我在使用Android 4.4的小米设备中遇到过同样的错误。您可以通过添加multidex在attachBaseContext()解决问题,并与普通的应用程序:

public class MyApplication extends Application { 

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

} 

然后下面的代码添加到您的应用程序build.gradle

android { 

    ... 

    dexOptions { 
     jumboMode true 
     javaMaxHeapSize "4g" 
    } 
    ... 
} 

我测试过的代码在Android 4.1 ,4.4,5.0和6.0