How to link a native library (.so + .jar) for reuse in new Eclipse Android projects?

I have a C ++ library and I made some JNI code to export to the Android world. I also created an Android app that uses my JNI interface.

To use the library, I imported all the * .java and * .h / *. Cpp files into the Eclipse App project (in the right folder), then I created the * .mk files for the NDK. I compiled the library using ndk-build and downloaded it to the target device using Eclipse. The application is working fine.

Now I would like to separate the application from the library. So, I compiled the name .jar, which contains the JNI Java interface files, then I compiled libname.so with ndk-build for C ++ stuff. Then I put name.jar in newproject / libs and libname.so in newproject / libs / armeabi. Consider the "newproject" application that I created without the source code of the library (I do not want to release the source code, only .jar and .so).

The result is a crashing application with a memory dump in LogCat. I used System.loadLibrary ("name") in a static context.

Can anybody help me?

+4
source share
1 answer

My procedure was fine. I found the problem: my application was loading the library and it was running C ++ code. By the way, the accident occurred at the beginning of the socket () call. I had to set the INTERNET permission to the manifest file.

+2
source

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


All Articles