Android Studio获取系统级签名方式

android:sharedUserId="android.uid.system" 系统签名

通过sharedUserId,拥有同一个User id的多个APK可以配置成运行在同一个进程中。那么把程序的UID配成android.uid.system,也就是要让程序运行在系统进程中。

1.将  build/target/product/security 下的 platform.pk8  和 platform.x509.pem拷贝到 编译服务器(Linux指令)下同一文件夹中,执行以下命令:

openssl pkcs8 -in platform.pk8 -inform DER -outform PEM -out shared.priv.pem -nocrypt

利用platform.pk8文件生成一个名为shared.priv.pem的中间文件

2.openssl pkcs12 -export -in platform.x509.pem -inkey shared.priv.pem -out shared.pk12 -name platform

利用platform.x509.pem文件生成另一个名为shared.pk12中间文件

Enter Export Password:  android

Verifying - Enter Export Password:  android

3.keytool -importkeystore -deststorepass android -destkeypass android -destkeystore platform.keystore -srckeystore shared.pk12 -srcstoretype PKCS12 -srcstorepass android -alias platform

deststorepass /destkeypass  分别对应上面输入的两个密码。

--alias 别名 platform

4.将生成的 platform.keystore 拷贝至本地磁盘(最好不带中文字符),按照gif中的流程进行配置。

Build --> Generate Signed Bundle or APK --> APK -->  图一 --> 图二。

5.需要在 build.fradle 中加入以下代码。(buildType之前)

    signingConfigs {
        debug   {
            storeFile file('D:\\platform.keystore')
            storePassword 'android'
            keyAlias 'platform'
            keyPassword 'android'
        }
        release   {
            storeFile file('D:\\platform.keystore')
            storePassword 'android'
            keyAlias 'platform'
            keyPassword 'android'
        }
    }

6.若出现报错,可优先查看是否有一一对应,生成platform.keystorey以及gradle中配置密码匹配(图三)。

或者可以尝试(Build)中 clean project --> rebuild project 。

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 16
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Brave & Real

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值