How to add multiple native libraries (.so) in IntelliJ

I have two third-party libraries, say libfoo.so and libbar.so . I find it hard to download both of these libraries. I copied them to the libs folder under the appropriate processor architecture (armeabi, mips and x86), and also set the Native libs directory in the Project Structure> Modules> Android> Structure section to specify libs in this folder. I can only load one library, but not another. If I try to load them one at a time (by deleting other libraries), it works fine. The exception that I get is:

 java.lang.UnsatisfiedLinkError: Couldn't load foo from loader dalvik.system.PathClassLoader 

What should I do to have IntelliJ or Android runtime to find both of these libraries?

+6
source share
1 answer

Fully find several native libraries to download. Just copy them to the / libs / CPU _ARCH / directory. However, all libraries must have the same architecture. If let say libfoo.so is armeabi, but libbar.so is x86, then only one will be copied (in my experience some time ago).

Then you can download it:

 static { //the following 3 are identical //System.load(context.getApplicationInfo().dataDir + "/lib/libfoo.so"); //Runtime.getRuntime().load(context.getApplicationInfo().dataDir + "/lib/libfoo.so"); System.loadLibrary("foo"); System.loadLibrary("bar"); } 

If System.loadLibrary () fails, you can try loading the full path using System.load () or Runtime.getRuntime (). load ()

0
source

All Articles