The environment...
I have a brand new Visual Studio 2015 Android NDK Solution. This contains 2 projects (the default template code that is generated by visual studio):
- A native activity. This is where I want to put Android specific code. It has some default code which fades the screen colour between green and black.
- A 'Packaging' project to help with deployment.
I have deployed this successfully to an Intel HAXM virtual device as well as to a real device connected via USB. All good so far.
I then added an Android dynamic library project (.so) - this is where I want to put core code (platform agnostic). I added a reference to this Core library from the native activity project.
Everything compiles and links fine. I can still create an .APK file.
Other info:
- Android SDK 5.1 (Android-22)
- Android NDK 21
- x86
- Clang 3.8
- C++ 11
- Not using Make files or Gradle
The problem...
Now whenever I deploy to the virtual/real device I get the following error (taken from logcat)
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.NATester/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app/com.NATester-2/lib/x86/libNATester.so
Things I have tried...
- changing the Core library to static (.a)
- checked the android device to see if the file exists - it does exist.
- Manually deploying the .APK to the android device.
Some articles have suggested using Java code to load the libraries - I want to avoid calling Java code e.g. System.LoadLibrary as this seems like a hack - I feel that it should be possible to to have a pure C++ application on android. I can't be the only person to run into this issue?!
This looks relevant but old and again an unnecessary hack for what must be very common situation - Can't load native shared library with dependencies in a native activity app - https://github.com/ikonst/android-dl
For what its worth, I am a seasoned C# developer with Visual Studio (15 years). I therefore take a lot of things for granted when developing apps - this is my first project using C++/Android and it seems more of a manual battle to get everything to work!