java.lang.NoClassDefFoundError:android/graphics/drawable/Icon [英] java.lang.NoClassDefFoundError: android/graphics/drawable/Icon

查看:122
本文介绍了java.lang.NoClassDefFoundError:android/graphics/drawable/Icon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我仅针对使用根电话(SM-G900R7 Android 4.4.2)的一位用户遇到此错误.错误是这样的:

So far I got this error only for one user, who uses a rooted phone (SM-G900R7 Android 4.4.2). The error is like this:

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)

我从不在代码中使用android.graphics.drawable.Icon,所有用法均来自android.support.v4.graphics.drawable.IconCompat,而且我也从未在代码中使用该类...

I never use android.graphics.drawable.Icon in my code, all usages are from android.support.v4.graphics.drawable.IconCompat and I also never use that class in my code...

顺便说一下,我的支持库是version 26.0.0, my minSdkVersion is 15 targetSdkVersion is 26.

Btw my support library is version 26.0.0, my minSdkVersion is 15 targetSdkVersion is 26.

谢谢

推荐答案

更新

此问题已在支持库27.0.0中修复.如果您进行更新,请不要忘记也更改compileSdkVersion 27.

当扩展View的类定义返回或采用不在类路径上的类型的参数的方法时,具有Android 4.4的三星设备会像这样崩溃.

Samsung devices with Android 4.4 crash like this when classes extending View define methods which return or take parameters of types that are not on classpath.

从支持库版本25.4.0开始,AppCompatImageViewAppCompatImageButton错误地覆盖了setImageIcon(Icon)方法.由于在API 23中引入了Icon类,因此该应用在具有API 19的三星设备上崩溃.

Starting with support library version 25.4.0 AppCompatImageView and AppCompatImageButton incorrectly overrides setImageIcon(Icon) method. Since Icon class was introduced in API 23 the app crashes on Samsung devices with API 19.

当您尝试覆盖 View.onApplyWindowInsets(WindowInsets) 时,类似的事情也会发生.

Similar thing happens when you try to override View.onApplyWindowInsets(WindowInsets).

直到正式解决此问题为止,如果您坚持使用较老版本的支持库,则我制作了appcompat-v7的修改版,其中所有setImageIcon方法的痕迹被删除.这意味着它不会在装有Android 4.4的三星电脑上崩溃.

Until this gets fixed in an official manner, If you're stuck with an older version of the support library, I made a modified version of appcompat-v7 where all traces of setImageIcon methods are removed. This means it won't crash on a Samsung with Android 4.4.

将其放在应用程序build.gradle的底部:

Put this at the bottom of your app's build.gradle:

repositories {
    maven { url "https://dl.bintray.com/consp1racy/maven" }
}

configurations.all {
    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'com.android.support' && requested.name == 'appcompat-v7') {
            details.useTarget 'net.xpece.android:support-appcompat-v7-fixed:26.1.0-1'
        }
    }
}

此代码将用描述的修改后的工件替换appcompat-v7依赖项.

This code will replace appcompat-v7 dependency with the described modified artifact.

当前唯一支持的修补程序版本是26.1.0.

Currently the only supported version of the fix is 26.1.0.

警告:在粘贴粘贴之前了解代码,在从未知来源获取代码时要格外小心!

Warning: Understand the code before copy-pasting, and always exercise caution when getting code from unknown sources!

这篇关于java.lang.NoClassDefFoundError:android/graphics/drawable/Icon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆