Android unit tests with Conscrypt
See original GitHub issueI 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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Conscrypt - Android Open Source Project
The Conscrypt module accelerates security improvements and improves device security without relying on OTA updates. It uses Java code and a native library ......
Read more >Include Unit and Functional Tests | Android Open Source Project
Unit tests can be executed standalone, but functional tests should be executed by using Trade Federation itself; they require an Android device.
Read more >Android Platform Testing | Android Open Source Project
A platform test typically interacts with one or more of the Android system services, or Hardware Abstraction Layer (HAL) layers, exercises the ...
Read more >Test Development Workflow | Android Open Source Project
Stay organized with collections Save and categorize content based on your preferences. To integrate tests into a platform continuous testing ...
Read more >Self-Instrumenting Tests Example | Android Open Source Project
This specifies the Trade Federation test class to use to execute the test and passes in the package on the device to be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried this:
and it worked for me.
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:
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.