Example C++ Library setup for specific use in Android
- This is an example using Cmake to create a native c++ Android library that can be built WITHOUT the use of Android.mk files.
- In addition it uses SWIG because I did not want to write the JNI bridge code.
- Also note that this is a great setup for developing native libraries (for Android) using the CLion IDE.
Requiremends
Build executable for host OS
mkdir -p build/os; cd build/os cmake ../../ && cmake --build .
Build shared library for Android
Requires a pre-built static libcurl.
Requires to update android-cmake
folder : android-cmake
x86
mkdir -p build/x86; cd build/x86
cmake -DCURL_ROOT=/Users/will/code/native/curl-android-ios/prebuilt-with-ssl/android -DLIBRARY=YES -DCMAKE_TOOLCHAIN_FILE=../../android-cmake/android.toolchain.cmake -DANDROID_NDK=/opt/android-ndk-r10d -DANDROID_ABI=x86 -DCMAKE_BUILD_TYPE=Release ../../ && cmake --build .
any Android NDK ABI can be used (armeabi, armeabi-v7a, arm64-v8a, x86_64, mips, mips64)
-DANDROID_ABI=armeabi
SWIG
- When making changes to the interface - Generate Java/JNI with SWIG
swig -c++ -java -package com.willkamp.swig -outdir swig Example.i
swig -c++ -java -package com.willkamp.swig -outdir swig NetCxx.i