JNI: cannot find library in java.library.path when running JUnit

I use JUnit to test an Android program that uses JNI and depends on several .so files that are in the same folder. When I run unit tests that call

System.loadLibrary("Name") 

This statement throws the following error:

UnsatisfiedLinkerError: no libName in java.library.path

Based on answers to other SO questions, I decided to try adding

-Djava.library.path=path/to/libs

as an argument to my emulator. Nothing helped. I even had my program print the value of java.library.path, and it included the correct path to my library, but for some reason still threw unsatisfiedLinkError. I can only conclude that something strange happens as a result of working with JUnit, because when I run my program normally (like an Android application), I don’t have such errors. What's happening?

+4
source share

Source: https://habr.com/ru/post/1546374/


All Articles