0

I added some C libraries in my Android project. According to some guides I found, I just have to create the folders and put the libraries there. According to the guidelines it is not necessary to do anything else.


|--app: 
|--|--src:
|--|--|--main
|--|--|--|--jniLibs
|--|--|--|--|--arm64-v8a
|--|--|--|--|--|—libhiddec.so
|--|--|--|--|--armeabi-v7a
|--|--|--|--|--|—libhiddec.so
|--|--|--|--|--X86
|--|--|--|--|--|--libhiddec.so

In addition, I downloaded the Cmake and NDK in SDK Manager.

I created this class to execute the function that I think is in the library.

public class NativeClass {

    static {
        System.loadLibrary("hiddec");
    }

    public static native int UIDCardToInt(String dato, int numero);
}

When I execute the project the following error appears

java.lang.UnsatisfiedLinkError: dlopen failed: library "libc.so.6" not found
JoshDM
  • 4,939
  • 7
  • 43
  • 72
  • Are the libraries correctly exporting functions via JNI? Do you have the correct Java functions as native to call into the C JNI functions? If you have no idea what I'm talking about, you need to read up on how JNI works. – Gabe Sechan Aug 05 '19 at 15:12
  • I didn't create the library .so, they supplied them to me. I only know that there is a function called UIDCardToInt inside. – Cristian Alvarez Hernandez Aug 05 '19 at 20:02
  • You are missing a piece; if the library doesn't have a JNI exported set of functions, this will not work; Java needs a bridge between the C/C++ code and the JVM. Check this answer to get a starting idea: https://stackoverflow.com/a/8246375/2684 – Martin Marconcini Aug 05 '19 at 20:06
  • You can do that without changing the original library though, by providing your own library that's a valid piece of JNI and calls into the original library. Just be very careful about object lifecycles of any data you need to pin – Gabe Sechan Aug 05 '19 at 20:23
  • s there a way to run the library without it being compiled for the application package? – Cristian Alvarez Hernandez Aug 13 '19 at 21:54

0 Answers0