我需要使用从Google来源(例如)使用SignApk.jar获得的系统密钥对APK进行签名。但是,每次我们尝试签名时,都会出现以下错误... 这是我们正在使用的命令(请注意,我们使用的是从Google下载的Android for Pixel 8.1的源代码)。
除此方法外,还有其他方法可以使用系统密钥对APK进行签名吗?
java -Xmx2048m -Djava.library.path="out/host/linux-x86/lib64" -jar prebuilts/sdk/tools/lib/signapk.jar -w build/make/target/product/security/platform.x509.pem build/make/target/product/security/platform.pk8 Unsigned-Apk.apk Signed_final_apk.apk
Error: Exception in thread "main" java.lang.ExceptionInInitializerError
at org.conscrypt.OpenSSLBIOInputStream.<init>(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(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-osx-x86_64, conscrypt_openjdk_jni]
at org.conscrypt.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:160)
at org.conscrypt.NativeCryptoJni.init(NativeCryptoJni.java:49)
at org.conscrypt.NativeCrypto.<clinit>(NativeCrypto.java:53)
... 9 more
答案 0 :(得分:0)
答案在Susmit提供的链接中。我遇到了同样的问题,我想您可以使用out/host/linux-x86/framework/signapk.jar
来解决。
我必须在命令中添加-Djava.library.path="out/host/linux-x86/lib64"
才能使其正常工作。
p.s。不要忘记将APK与zipalign
对齐:-)