android target Version升为28的躺坑之路

2019-06-23  本文已影响0人  淋雨人1201

target Version28的行为变更


隐私权限变更


如果你的应用以 Android 9 为目标平台,应牢记以下行为变更。 对设备序列信息和 DNS 信息进行的这些更新可增强用户隐私保护。

框架安全性变更


Android 9 包含可提升应用安全性的多个行为变更,但这些变更仅在你的应用以 API 级别 28 或更高级别为目标平台时才会生效:

链接变更


  <uses-library android:name="org.apache.http.legacy" android:required="false"/>

注:拥有最低 SDK 版本 23 或更低版本的应用需要 android:required="false" 属性,因为在 API 级别低于 24 的设备上,org.apache.http.legacy 库不可用。 (在这些设备上,Apache HTTP 类在 bootclasspath 中提供。)

作为使用运行时 Apache 库的替代,应用可以在其 APK 中绑定自己的 org.apache.http 库版本。 如果进行此操作,必须将该库重新打包(使用一个类似 Jar Jar 的实用程序)以避免运行时中提供的类存在类兼容性问题。

界面变更


前台服务


NotificationManager


趟过的坑


1、在Android 8.0(API level 26)上,Activity出现了一个莫名其妙的crash,异常信息如下:
java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
问题原因

这个问题只出现在api26

//Need to pay attention mActivityInfo.isFixedOrientation() and ActivityInfo.isTranslucentOrFloating(ta)
    if (getApplicationInfo().targetSdkVersion >= O_MR1 && mActivityInfo.isFixedOrientation()) {
        final TypedArray ta = obtainStyledAttributes(com.android.internal.R.styleable.Window);
        final boolean isTranslucentOrFloating = ActivityInfo.isTranslucentOrFloating(ta);
        ta.recycle();
        //Exception occurred
        if (isTranslucentOrFloating) {
            throw new IllegalStateException(
                    "Only fullscreen opaque activities can request orientation");
        }
    }
解决方案
  if (Build.VERSION.SDK_INT == 26) {
   setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
  } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }    
2、使用appche网络库崩溃
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.util.EncodingUtils" on path: DexPathLis。。。。
3、通知栏收到消息后无法正常显示
4、通知栏展示mini播放器后,调用notify时有媒体声音提醒
上一篇下一篇

猜你喜欢

热点阅读