Update
该问题已在支持库 27.0.0 中修复。如果更新不要忘记更改compileSdkVersion 27
以及。
怎么了?
当类扩展时,搭载 Android 4.4 的三星设备会像这样崩溃View
定义返回或采用不在类路径上的类型参数的方法。
从支持库版本 25.4.0 开始AppCompatImageView
and AppCompatImageButton
错误地覆盖setImageIcon(Icon)
方法。自从Icon
该类在 API 23 中引入,应用程序在 API 19 的三星设备上崩溃。
当您尝试覆盖时会发生类似的情况View.onApplyWindowInsets(WindowInsets) https://stackoverflow.com/questions/35028395/android-view-windowinsets-classnotfoundexception.
支持库 26.1.0 的解决方法
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 底部:
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
与所描述的修改工件的依赖性。
目前唯一支持的修复版本是 26.1.0。
Warning:在复制粘贴之前先了解代码,并在从未知来源获取代码时务必谨慎!