0

I need to sign an APK using the system keys obtained from Google's source (As an example) using SignApk.jar. However, everytime we try to Sign we get the error below... This is the command we are using (Please note we are using the Source code downloaded from Google for Android 8.1 for the Pixel).

Besides this method, is there another way to sign an APK with the system key?

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
Rene
  • 1
  • 1
  • Possible duplicate of [Signing my android application as system app](https://stackoverflow.com/questions/37586255/signing-my-android-application-as-system-app) – Susmit Agrawal Jul 14 '18 at 19:44
  • It is similar to that thread, but in that thread they do not discuss any issues with the process. Should I ask my question in that thread? – Rene Jul 17 '18 at 16:37

1 Answers1

0

The answer is in the link that Susmit supplied. I had the same issue, and I think you can solve it by using out/host/linux-x86/framework/signapk.jar.

I had to add -Djava.library.path="out/host/linux-x86/lib64" to the command to make it work.

p.s. don't forget to align your APK with zipalign :-)

Bayou
  • 3,293
  • 1
  • 9
  • 22