I took the android native activity sample from Android Studio and replaced the app glue implementation by my own implementation of native activity.
So here is my Cmake file which almost the same as in the sample:
cmake_minimum_required(VERSION 3.4.1)
#my implementation
add_library(android-impl STATIC
C:/android_libs/native-impl/Activity.cpp
)
# now build app's shared lib
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
add_library(my-app SHARED
main.cpp
)
#add include directories
target_include_directories(my-app PRIVATE
C:/android_libs/native-impl/)
# add lib dependencies
target_link_libraries(my-app
android
android-impl
EGL
GLESv1_CM
log)
And I also specified in the Android manifest file the name of my shared lib like this:
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="my-app" />
It all compiles, but when I run on my device it instantly throws an error:
Caused by: java.lang.IllegalArgumentException: Unable to load native library: /data/app/com.nativetest.myapp-1/lib/arm/libmy-app.so
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nativetest.myapp/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app/com.nativetest.myapp-2/lib/arm/libmy-app.so
I don't understand because I have copied the same Cmake file from the sample provided for native activity and just replaced app glue with my implementation, and used different name for my shared library.
Here are the files from the sample that I used: Cmakelist.txt AndroidManifest.xml
Is there something else that I need to modify ?