大家好,又见面了,我是你们的朋友全栈君。
在开发的过程中,如果需要设置当前的应用为系统应用,需要两步:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.localmediaplayerdemo"
android:sharedUserId="android.uid.system">
04/24 18:02:52: Launching 'mobile' on ×××Android Device.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE
List of apks:
[0] '/**/**/APK name /mobile/build/outputs/apk/debug/mobile-debug.apk'
Installation failed due to: 'Failed to commit install session 1758990893 with command cmd package install-commit 1758990893. Error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: Reconciliation failed...: Reconcile failed: Package com.example.apkname has no signatures that match those in shared user android.uid.system; ignoring!'
Retry
生成系统签名,首先需要下面的两个系统签名文件: platform.pk8 platform.x509.pem 这两个文件可以从Android源码中获取,具体路径为: build/target/product/security/ 将上面的两个文件放到同一个文件夹,同时也将自己生成的签名文件放置在这个文件夹下,从gitHub上下载工具keytool-importkeypair 执行下面的命令就可以生成系统签名文件了。
./keytool-importkeypair -k SignDemo.jks -p 123456 -pk8 platform.pk8 -cert platform.x509.pem -alias platform
其中: SignDemo.jks是签名文件 123456是storePassword和keyPassword的密码 platform是别名
signingConfigs {
platform {
storeFile file("SignDemo.jks")
storePassword '123456'
keyAlias 'platform'
keyPassword '123456'
}
}
上面命令的意思也就是将签名文件转换成系统签名文件。
有时候会出现下面的错误:
Error decrypting key
139637230543296:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../crypto/asn1/tasn_dec.c:1149:
139637230543296:error:0D06C03A:asn1 encoding routines:asn1_d2i_ex_primitive:nested asn1 error:../crypto/asn1/tasn_dec.c:713:
139637230543296:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../crypto/asn1/tasn_dec.c:646:Field=version, Type=PKCS8_PRIV_KEY_INFO
unable to load private key
140642992083392:error:0909006C:PEM routines:get_name:no start line:../crypto/pem/pem_lib.c:745:Expecting: ANY PRIVATE KEY
Importing "platform" with SHA1 Fingerprint=57:3D:8B:63:41:84:95:29:43:CB:AD:67:7D:93:2D:03:83:D3:08:CE
正在将密钥库 /tmp/keytool-importkeypair.LHJB/p12 导入到 ./debug.keystore...
keytool 错误: java.io.FileNotFoundException: /tmp/keytool-importkeypair.LHJB/p12 (没有那个文件或目录)
是因为platform.pk8文件或者platform.x509.pem文件有问题,从源码当中copy一份就可以了。
参考文档: https://blog.csdn.net/qq_34744658/article/details/107949895 https://www.freesion.com/article/242659750/
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151961.html原文链接:https://javaforall.cn