在ASOP源码中对apk使用以下命令进行签名时
java -Xms512m -jar signapk.jar -w platform.x509.pem platform.pk8 to_be_signed.apk demo_Signed.apk
会出现报错提示:
Exception in thread “main” java.lang.ExceptionInInitializerError
at org.conscrypt.OpenSSLBIOInputStream.(OpenSSLBIOInputStream.java:34)
at org.conscrypt.OpenSSLX509Certificate.fromX509PemInputStream(OpenSSLX509Certificate.java:129)
at org.conscrypt.OpenSSLX509CertificateFactory$1.fromX509PemInputStream(OpenSSLX509CertificateFactory.java:226)
at org.conscrypt.OpenSSLX509CertificateFactory 1. f r o m X 509 P e m I n p u t S t r e a m ( O p e n S S L X 509 C e r t i f i c a t e F a c t o r y . j a v a : 222 ) a t o r g . c o n s c r y p t . O p e n S S L X 509 C e r t i f i c a t e F a c t o r y 1.fromX509PemInputStream(OpenSSLX509CertificateFactory.java:222) at org.conscrypt.OpenSSLX509CertificateFactory 1.fromX509PemInputStream(OpenSSLX509CertificateFactory.java:222)atorg.conscrypt.OpenSSLX509CertificateFactoryParser.generateItem(OpenSSLX509CertificateFactory.java:100)
at org.conscrypt.OpenSSLX509CertificateFactory.engineGenerateCertificate(OpenSSLX509CertificateFactory.java:278)
at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:339)
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-linux-x86_64, conscrypt_openjdk_jni-linux-x86_64-fedora, conscrypt_openjdk_jni]
at org.conscrypt.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:176)
at org.conscrypt.NativeCryptoJni.init(NativeCryptoJni.java:49)
at org.conscrypt.NativeCrypto.(NativeCrypto.java:53)
原因是缺少参数:-Djava.library.path
,加上该参数
java -Xmx512m -Djava.library.path=./prebuilts/sdk/tools/linux/lib64/ -jar signapk.jar -w platform.x509.pem platform.pk8 tobe_signed.apk demo_Signed.apk