Android P 9.0系统APP安装闪退问题

问题描述:

在Android9.0上APP安装成功后,运行直接闪退。报错如下:

java.lang.SecurityException: Call from user 0 as user 1 without permission INTERACT_ACROSS_USERS or INTERACT_ACROSS_USERS_FULL not allowed.

 

解决方案:

1、在清单文件AndroidManifest.xml中修改如下:

(1)添加权限:

<permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" android:protectionLevel="signature"/>

(2)在<application>标签中添加相关属性(为了解决HTTP请求问题,Android9.0默认是关闭的):

android:protectionLevel="signature"
android:usesCleartextTraffic="true"
<!--android9闪退-->
<uses-library
    android:name="org.apache.http.legacy"
    android:required="false" />

(3)如果你使用的是自定义的Application,那么一定要注意方法命名问题,比如:getUserId()是和系统中的方法重名了。否则,也会导致闪退。

Android P 9.0系统APP安装闪退问题