Search code examples
androidjava-native-interfacereverse-engineering

Package name in .so file in android apk


Android can use .so file through JNI. The native function in C/C++ is bound to a Java function.

I want to use other developers' .so file (I don't have the source code). I know the interface of the native function, but I have faced some difficulties. It seems that the .so file is hard coded to bind for a certain package name.

Is there any way for me to use other developers' .so file?

If not, is it possible to decompile the .so file and make it work?


Solution

  • You could create a package with the name that the shared object expects, in which you have a wrapper class whose only purpose is to load the library and provide the native methods to clients using this class.

    Import that package into your own activity's package (or wherever you want to use it) and call the native methods through the wrapper class.