在这里只是记录一下在项目中遇到的Android9.0崩溃问题
1.问题:为了适配Android 9.0的刘海屏,使用谷歌推荐的方法:DisplayCutout类,但是使用后,如下代码中:
WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
activity.getWindow().setAttributes(lp);
崩溃错误日志:
java.lang.NoSuchFieldError: No field layoutInDisplayCutoutMode of type I in class Landroid/view/WindowManager$LayoutParams; or its superclasses (declaration of 'android.view.WindowManager$LayoutParams' appears in /system/framework/framework.jar!classes2.d
通过这篇文章:原文链接:https://wetest.qq.com/lab/view/406.html?from=content_csdnblog
了解到需要进行非SDK API适配,非 SDK API 名单总共分为三类:light grey list (浅灰名单)、dark grey list (深灰名单)、dark list(黑名单),而深灰名单和黑名单是不允许调用的,上方标红方法就是在深灰名单中( 名单查看上方原文链接),所以导致的崩溃。
2.问题:android-async-http1.4.8在Android9.0中报如下错误
解决办法:升级android-async-http到1.4.9,问题解决
3.问题:xutils2.4.6中报NotFountException错误:
解决办法:升级xutils2.4.6到xutils3,问题解决
关于2,3问题,查看相关文章说Android P在新系统中,对使用老旧Target API的应用作了严格限制。Google在SDK增加了一项MIN_SUPPORTED_TARGET_SDK_INT新规,如果App的SDK版本低于v17,那么App将无法兼容Android P。这意味着安卓4.1包括以前版本的App,将会在Android P中遭到淘汰。原文链接:https://blog.csdn.net/xJ032w2j4cCjhOW8s8/article/details/79662424