有时候apk需要一些系统权限,我们能拿到系统的签名文件就可以
1、在Manifest.xml里添加
android:sharedUserId="android.uid.system"
2、使用系统签名工具,签名文件来签名apk
java -jar signapk.jar platform.pk8 platform.x509.pem test.apk test_sign.apk
这样签名过的文件test_sign.apk就具有了系统权限
记录一个低级错误,签名的时候,一直报错,百思不解
java.security.cert.CertificateParsingException: signed fields invalid
at sun.security.x509.X509CertImpl.parse(X509CertImpl.java:1718)
at sun.security.x509.X509CertImpl.<init>(X509CertImpl.java:177)
at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:90)
at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:305)
at com.android.signapk.SignApk.readPublicKey(SignApk.java:143)
at com.android.signapk.SignApk.main(SignApk.java:744)
最后发现,原来是platform.pk8跟platform.x509.pem顺序反了。
写成了使用java -jar signapk.jar platform.pk8 platform.x509.pem test.apk test_sign.apk命令下失败