Development environment: Win10 AndroidStudio 3.1.2 NDK17

1

NKD development refer to: blog.csdn.net/ezconn/arti…

2

The UnsatisfiedLinkError exception may be caused by one of the following reasons:

1) The NDK 17 version is too high, it should be changed to NDK16, maybe the older version no longer supports NDK-build compilation

2).h file name or function name is consistent with the path of Java Native methods (static registration needs to be consistent)

3) whether the placement of the.so library needs to be configured in build.gradle; For example, put it under the app directory of the project and under the libs directory of the same level as SRC, which needs to be configured

sourceSets.main {
   jniLibs.srcDir 'libs'
}
Copy the code

The Java equivalent of the jniLibs directory in the project’s main directory does not need to configure code similar to the above

4) Load the file name of the generated dynamic library, the name specified when generating.so, LOCAL_MODULE := Java2c in android. mk whether the three are consistent; For example, mine are Java2c;

So static {system.loadLibrary ("Java2c"); }Copy the code
So file NDK {moduleName "Java2c" // Generate so name abiFilters "armeabi", "armeabi-v7a", "x86" // output the so library specified under the three ABI architectures. }Copy the code