• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Android 8.0以后应用签名方法

互联网 diligentman 1周前 (10-18) 16次浏览

以下皆以RK3368-9.0为例
一般应用签名方法

java -jar signapk.jar platform.x509.pem platform.pk8 source.apk signed_source.apk

其中

platform.x509.pem 位于 Andoird/build/make/target/product/security/platform.x509.pem

platform.pk8 位于 Android/build/make/target/product/security/platform.pk8
带有系统权限的特殊应用签名方法

AndroidManifest中有android:sharedUserId=“android.uid.system”

用上述方法签名会出现报错如下:

Exception in thread “main” java.lang.ExceptionInInitializerError

at org.conscrypt.OpenSSLBIOInputStream.(OpenSSLBIOInputStream.java:34)

at org.conscrypt.OpenSSLX509Certificate.fromX509PemInputStream(OpenSSLX509Certificate.java:119)

at org.conscrypt.OpenSSLX509CertificateFactory$1.fromX509PemInputStream(OpenSSLX509CertificateFactory.java:220)

at org.conscrypt.OpenSSLX509CertificateFactory$1.fromX509PemInputStream(OpenSSLX509CertificateFactory.java:216)

at org.conscrypt.OpenSSLX509CertificateFactory$Parser.generateItem(OpenSSLX509CertificateFactory.java:94)

at org.conscrypt.OpenSSLX509CertificateFactory.engineGenerateCertificate(OpenSSLX509CertificateFactory.java:272)

at java.security.cert.CertificateFactory.generateCertificate(Unknown Source)

at com.android.signapk.SignApk.readPublicKey(SignApk.java:184)

at com.android.signapk.SignApk.main(SignApk.java:1007)

Caused by: java.lang.IllegalArgumentException: Failed to load any of the given libraries: [conscrypt_openjdk_jni-windows-x86_32, conscrypt_openjdk_jni]

at org.conscrypt.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:160)

at org.conscrypt.NativeCryptoJni.init(NativeCryptoJni.java:49)

at org.conscrypt.NativeCrypto.(NativeCrypto.java:53)

… 9 more

原因:缺少库

解决办法:

1 将缺少的库文件复制到签名的路径

Android/prebuilts/sdk/tools/linux/lib64/libconscrypt_openjdk_jni.so

2 修改签名命令为

java -Djava.library.path=. -jar signapk.jar platform.x509.pem platform.pk8 source.apk signed_source.apk

3 需在linux环境中使用,若在windows中会出现报错如下:

错误: 找不到或无法加载主类 .library.path=.

补充:签名脚本

#!/bin/sh

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$PATH

if [ $# -eq 1 ]; then
java -Djava.library.path=. -jar signapk.jar platform.x509.pem platform.pk8 $1 signed_${1}
echo "succeed!file : signed_${1} "
else
echo "./sign.sh xxx.apk"
exit 1
fi


喜欢 (0)