You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am unable to run android unit tests when using org.conscrypt:conscrypt-android:2.0.0 as my dependency. I am running into following error when trying to add OpenSSLProvider as a Security Provider :
java.lang.UnsatisfiedLinkError: no conscrypt_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:28)
at org.conscrypt.NativeCrypto.<clinit>(NativeCrypto.java:65)
at org.conscrypt.OpenSSLProvider.<init>(OpenSSLProvider.java:60)
at org.conscrypt.OpenSSLProvider.<init>(OpenSSLProvider.java:53)
at org.conscrypt.OpenSSLProvider.<init>(OpenSSLProvider.java:49)
Since unit tests run on the local machine, it fails to link native libraries that are compiled for different platform(mac in my case)? Is there a workaround/solution available for this?
PFA a simple android project where running the unit test reproduces the issue ConscryptRepro.zip
Ah, I see the problem. Yeah, as far as I know (or have been able to find on the Internet), there isn't a simple solution to this.
As you note, the local unit tests run on your local machine in a JVM, rather than in an Android environment. As a result, the Android dependency (which is packaged differently and such) doesn't work out of the box, but the OpenJDK dependency does. (If you change your dependency to org.conscrypt:conscrypt-openjdk-uber:2.0.0 in the sample project, you can see that it works.)
Unfortunately, I wasn't able to find a good way to deal with that. The main things people mentioned were:
Skip the local unit tests and only use Android unit tests, so you never deal with this situation
Rewrite the classpath for your tests in gradle to remove the Android dependency and replace it with the OpenJDK one
Use LD_LIBRARY_PATH to point the library loader at the Android library, which will probably work (since we don't use much from the NDK) but doesn't really come with any guarantees
Sadly, I don't think this is something we can improve on the Conscrypt side. Fundamentally, native library loading works differently in Android and on a JVM, and we need to package things so they work on Android in the Android distribution. If you find that one of those solutions works well for you, though, we could add some docs that show how it's done to help future users.
Skip the local unit tests and only use Android unit tests, so you never deal with this situation
Do you mean Android instrumented tests because Android unit tests(which I think is same as local unit tests you mentioned.) are the ones we cannot run.
Sadly, I don't think this is something we can improve on the Conscrypt side.
I was thinking about packaging native libraries for armeabi-v7a, and arm64-v8a in the uber version since the uber version is supposed to have the shared libraries for all of the published platforms ?? In this case I can use the uber version for all both test and source code. Please let me know you thoughts. Thanks!
Do you mean Android instrumented tests because Android unit tests(which I think is same as local unit tests you mentioned.) are the ones we cannot run.
Yeah, instrumented tests.
I was thinking about packaging native libraries for armeabi-v7a, and arm64-v8a in the uber version since the uber version is supposed to have the shared libraries for all of the published platforms ?? In this case I can use the uber version for all both test and source code. Please let me know you thoughts. Thanks!
Unfortunately that won't work. The Android and JVM library loaders look in different places for native libraries, so putting ARM native libraries in the JVM jar won't make them load on Android (in the same way that x86 libraries are already in the AAR, but the JVM native library loader can't find them). The Java code is also different between the Android and OpenJDK builds.
I was thinking about packaging native libraries for armeabi-v7a, and arm64-v8a in the uber version since the uber version is supposed to have the shared libraries for all of the published platforms ?? In this case I can use the uber version for all both test and source code. Please let me know you thoughts. Thanks!
This would be a big help. Trying to do anything with Conscrypt on a Raspberry Pi is really tough. With the announcement of Apple Silicon, there may also be increased demand for ARM builds.
Activity
flooey commentedon Mar 28, 2019
Ah, I see the problem. Yeah, as far as I know (or have been able to find on the Internet), there isn't a simple solution to this.
As you note, the local unit tests run on your local machine in a JVM, rather than in an Android environment. As a result, the Android dependency (which is packaged differently and such) doesn't work out of the box, but the OpenJDK dependency does. (If you change your dependency to
org.conscrypt:conscrypt-openjdk-uber:2.0.0in the sample project, you can see that it works.)Unfortunately, I wasn't able to find a good way to deal with that. The main things people mentioned were:
Sadly, I don't think this is something we can improve on the Conscrypt side. Fundamentally, native library loading works differently in Android and on a JVM, and we need to package things so they work on Android in the Android distribution. If you find that one of those solutions works well for you, though, we could add some docs that show how it's done to help future users.
desokroshan commentedon Mar 28, 2019
Do you mean Android instrumented tests because Android unit tests(which I think is same as local unit tests you mentioned.) are the ones we cannot run.
I was thinking about packaging native libraries for armeabi-v7a, and arm64-v8a in the uber version since the uber version is supposed to have the shared libraries for all of the published platforms ?? In this case I can use the uber version for all both test and source code. Please let me know you thoughts. Thanks!
flooey commentedon Mar 28, 2019
Yeah, instrumented tests.
Unfortunately that won't work. The Android and JVM library loaders look in different places for native libraries, so putting ARM native libraries in the JVM jar won't make them load on Android (in the same way that x86 libraries are already in the AAR, but the JVM native library loader can't find them). The Java code is also different between the Android and OpenJDK builds.
desokroshan commentedon Mar 28, 2019
That makes sense. Thanks for the prompt response. This issue should be good to close.
pkpfr commentedon Jun 27, 2020
This would be a big help. Trying to do anything with Conscrypt on a Raspberry Pi is really tough. With the announcement of Apple Silicon, there may also be increased demand for ARM builds.
StefanLobbenmeier commentedon Feb 24, 2021
I would very much appreciate documentation on this
I tried adding
but that did not fix it
StefanLobbenmeier commentedon Feb 24, 2021
It looks like
is the way to go
icksonb commentedon Mar 26, 2021
I tried this:
and it worked for me.
StefanLobbenmeier commentedon Mar 26, 2021
What about androidTest, do they also work with that setup?
yinyinnie commentedon Sep 18, 2025
yeah. i tried this too:
and it worked for me.