13

I want to sign my apk, so I executed the following command:

java -jar signapk.jar platform.x509.pem platform.pk8 app-debug.apk ~/Desktop/test.apk

but I got the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no conscrypt_openjdk_jni in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at org.conscrypt.NativeCryptoJni.init(NativeCryptoJni.java:25) at org.conscrypt.NativeCrypto.(NativeCrypto.java:54) 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(CertificateFactory.java:339) at com.android.signapk.SignApk.readPublicKey(SignApk.java:182) at com.android.signapk.SignApk.main(SignApk.java:1087)

How to solve this error?

(openjdk version "1.8.0_141" OpenJDK Runtime Environment (build 1.8.0_141-8u141-b15-3~14.04-b15) OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode) )

cong
  • 1,105
  • 1
  • 12
  • 29

2 Answers2

17
java -Xmx2048m -Djava.library.path="out/host/linux-x86/lib64" \
    -jar out/host/linux-x86/framework/signapk.jar \
    -w build/target/product/security/platform.x509.pem \
    build/target/product/security/platform.pk8 \
    FileNeedSign.apk FileNeedSign_Signed.apk
DeeHY
  • 206
  • 2
  • 6
  • 9
    Even though this is the accepted answer to be more helpful please add description to your answer and the reason why additional arguments had fixed the issue – Ali Ezzat Odeh Jul 10 '19 at 13:18
  • To find out your java.library.path, type this in your cmd `java -XshowSettings:properties` (Scroll up to find your library path, it will show help options too when you use that command) – Shah Aug 28 '19 at 23:05
  • didn't help for Windows10: still `no conscrypt_openjdk_jni-windows-x86_64 in java.library.path` – Alexey Kolosov Apr 11 '22 at 12:25
  • Me too didn't help for Windows10: still no conscrypt_openjdk_jni-windows-x86_64 in java.library.path – kishan verma Apr 18 '23 at 05:52
  • Worked for me on Linux with -Djava.library.path="sdk/tools/linux/lib64" but only after I cloned the Android SDK repo with: `git clone https://android.googlesource.com/platform/prebuilts/sdk` – santiago Jul 31 '23 at 15:12
2

I'm using Jetty, Kotlin, Java 8, and Maven. My solution was twofold. First in pom.xml, add Conscrypt:

<dependency>
    <groupId>org.conscrypt</groupId>
    <artifactId>conscrypt-openjdk</artifactId>
    <version>2.2.1</version>
    <classifier>linux-x86_64</classifier>
</dependency>

Note the <classifier> which needs to be right for your operating system. Pick one from the list here: https://github.com/google/conscrypt/

I like to put my configuration right in the code. Flame me if you like. I followed the instructions here: https://www.eclipse.org/jetty/documentation/current/configuring-ssl.html#conscrypt So right before setting up Jetty's sslContextFactory, I had to add:

    Security.addProvider(new OpenSSLProvider())

then after:

    // SSLv2Hello and SSLv3 are outdated and insecure.
    // TLSv1.3 works with Conscrypt, but not Java 8!
    sslContextFactory.setExcludeProtocols("SSLv2Hello", "SSLv3", "TLSv1.3")
    sslContextFactory.setProvider("Conscrypt");

I think that's what cleared it up. I made a lot of changes today.

I had a separate issue which was that my localhost SSL certificate was invalid. I started with this: Can you use a service worker with a self-signed certificate? but ended up grabbing a cert from a server and editing my /etc/hosts file to make localhost look like that server.

Art
  • 1,302
  • 13
  • 25
GlenPeterson
  • 4,866
  • 5
  • 41
  • 49