So library for the Android version of the connection library (*.so file) role: As long as the development to provide us with interface instructions, we can directly do interface testing, no longer need to grab a packet to analyze, to reduce the technical difficulty of interface testing
The general project calls its own so by placing the so file directly under Libs/armeabi, then system.loadlibrary ("XXX") in the code, and then public native static int xxx_xxx_xxx () Next, you can call the Xxx_xxx_xxx () method directly;
But one problem is that you must align the class name, and you cannot tune a function that is not open to Java
For example: These are the only calls that are open to the outside, because this involves java,c the platform call
The next step is to solve how this kind of undefined method calls
The way to do this is to create your own so file, call third-party so in your own so file, and call your own so in the program.
Based on the last (Android Dynamic link Library series-writing so)
1. Write a so yourself first
Then add the following to so:
Jstring Java_com_abso_jnigg2_callxg (jnienv* env, Jobject thiz)
{
jstring ret;
So path:/data/data/The package name of my program/lib/my so file name
void * FileHandle = Dlopen ("/data/data/com.abso/lib/libjninetutil.so", Rtld_lazy);
void * FileHandle = Dlopen ("/data/data/com.abso/lib/libgame.so", Rtld_lazy); ###### #com. ABSO is our package name
if (filehandle)
{
char * (* Funcptra) (void) = NULL;
Funcptra = Dlsym (FileHandle, "tiffgetversion");
if (Funcptra)
{
ret = (*env)->newstringutf (env, Funcptra ());
}
Else
{
ret = (*env)->newstringutf (env, "Dlsym zlibversion failed!");
}
Dlclose (FileHandle);
}
Else
{
ret = (*env)->newstringutf (env, "Dlopen failed!");
}
return ret;
}
So the code is to let go of the Three Kingdoms for example
2. Then add the code and then run Ndk-build to generate our
3. Copy libgame.so to this directory
4. Call in Android
5. After running the program, the results are as follows:
Android third-party dynamic link library so called to resolve non-Java-open function calls to resolve class name alignment issues