[英]Android: Fatal Exception: java.lang.NoClassDefFoundError (4.4.2 on Samsung)
This crash appears only on Samsung with 4.4.2 SDK version and in rooted mode (Crashlytics informations): 此崩溃仅出现在具有4.4.2 SDK版本的三星和root用户模式(Crashlytics信息)中:
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)
I can't understand why. 我不明白为什么。 My projet is correctly configured with Dex notion: 我的projet正确配置了Dex概念:
In Gradle file: 在Gradle文件中:
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'
...
And My App extends MultiDexApp: 我的应用程序扩展了MultiDexApp:
public class MyApplication extends MultiDexApplication { ...
Have you got some explanations about this crash? 你有关于这次事故的解释吗?
Thank you very much guys 非常感谢你们
I've experienced the same error in Xiaomi Device with Android 4.4. 我在使用Android 4.4的小米设备中遇到了同样的错误。 You can solve the problem by adding the multidex in attachBaseContext()
and with the plain Application: 您可以通过在attachBaseContext()
和普通应用程序中添加multidex来解决问题:
public class MyApplication extends Application {
@Override protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Then add the following code to your app build.gradle
: 然后将以下代码添加到您的应用build.gradle
:
android {
...
dexOptions {
jumboMode true
javaMaxHeapSize "4g"
}
...
}
I've tested the code on Android 4.1, 4.4, 5.0, and 6.0 我在Android 4.1,4.4,5.0和6.0上测试了代码
Multidex is working very unstable prior to Android 5.0. 在Android 5.0之前,Multidex工作非常不稳定。 I can't run it properly for 2 my projects. 对于我的2个项目,我无法正常运行它。 Try to update all build tools to last version and Disable instant Run. 尝试将所有构建工具更新为上一版本并禁用即时运行。 For example some libraris not support multidex - https://issuetracker.google.com/issues/63999442 例如,某些图书馆不支持multidex - https://issuetracker.google.com/issues/63999442
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.