// [DllImport ("kurt2lib-release")]
// [DllImport ("kurt2")]
// [DllImport ("Kurt2")]
// [DllImport ("com.mycompany.kurt2lib")]
[DllImport ("kurt2lib")] // the actual library module name in Android Studio
private static extern string doit( int arg1, int arg2);
In all cases I get a DllNotFoundException.
What is that name supposed to be?
NOTE: when I unzip my .apk file I cannot find that .aar file inside it. Is this because it has been included in some sub-resource within the Unity resources structure, or is this my core problem?
What does your kur2lib-release.aar library contain ?
If you’re creating a native library, you should compile that into an .so file using NDK. Did you perform this step ?
Usually, if you’d like to have some native code on android, you would do the following:
Develop the native “plugin” functionality in native code (e.g: in C or CPP on Android).
Compile using NDK into an .so library.
Import the .so file to your project (check “Android”)
If the library is called “libmyplugin.so”, you would write [DllImport (“myplugin”)] on top of the methods that should call into native code (you should also define these in a header file).
In this process, there’s really no point in including the compiled native library inside an .aar file (unless you have some java code that also requires access to the native plugin code).
Come here for a solution, ended up giving a solution I just found.
In case you didn’t get it to work yet, aar works like a zip file of libraries and resources. To load the ndk library use name you specified in the Android.mk file in :
LOCAL_MODULE := modulename
This mean you can include multiple libraries in the same file.