INSTALL_FAILED_SHARED_USER_INCOMPATIBLE出现的原因和解决办法

admin 2021-12-08 AM 5634℃ 0条

最近和同事开发一个Android控制板上APP远程重启的功能,重启的原理很简单,只要通过Android API调用来实现,详细的教程及可能的问题见本博客:Neither user xxx nor current process has android.permission.REBOOT 的解决办法

但在开发调试的过程中,Idea抛出如下的错误信息:

Installation did not succeed.
The application could not be installed: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE

List of apks:
[0] 'E:\xx-code\xx-xx\aaaa\app\build\outputs\apk\debug\xxx-debug-v1.3.6-debug.apk'

Installation failed due to: 'Failed to commit install session 1605276076 with command pm install-commit 1605276076. Error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: Package couldn't be installed in /data/app/cn.xx.xxx-1: Package cn.xx.xxx has no signatures that match those in shared user android.uid.system; ignoring!'
Retry

解读一下log的信息:
1、Installation did not succeed ,已经尝试安装,但安装不成功。
2、抛出异常信息:INSTALL_FAILED_SHARED_USER_INCOMPATIBLE,这个异常信息跟Share_user相关。

联想到要启用reboot功能,需要在manifest中配置:

android:sharedUserId="android.uid.system"

这个配置是让APP列为System级别的APP,而系统级别的APP在安装的时候需要校验其签名是否为系统签名。用通俗的话就是说:如果APP不是系统签名,那么配置android:sharedUserId="android.uid.system"将会报错。

而我们在开发过程中的设备一般都很复杂,很少能一个设备弄一个系统签名,所以报这个错就不奇怪。

解决的办法:当非正式包的时候,去掉manifest中的android:sharedUserId="android.uid.system"即可。

标签: Android

非特殊说明,本博所有文章均为博主原创。

评论已关闭