This example demonstrates how to :
- generate a library containing a procedure written in ARMv7 GNU ASsembly
- call this procedure from a Android app using the JNI
- call a Java method, defined in the Android app, from the Assembly procedure using the JNI
- GNU AS
- Gold linker
- An ARM Android phone/emulator on which you have installation privileges
Run make
from this folder
Run the following commands :
# cross compiler prefix. Remove if you're assembling from an ARM machine
export PREFIX="armv7a-hardfloat-linux-gnueabi"
export APP_DIR="./apk"
export LIBNAME="libarcane.so"
$PREFIX-as -o decypherArcane.o decypherArcane.s
$PREFIX-ld.gold -shared --dynamic-linker=/system/bin/linker -shared --hash-style=sysv -o $LIBNAME decypherArcane.o
mkdir -p $APP_DIR/app/src/main/jniLibs/armeabi{,-v7a}
cp $LIBNAME $APP_DIR/app/src/main/jniLibs/armeabi
cp $LIBNAME $APP_DIR/app/src/main/jniLibs/armeabi-v7a
- The Android NDK path in your system's PATH directory
- On Windows, run 'mkbuild.bat'
- On Linux, run 'mkbuild.sh'
- Connect your ARMv7 Android phone/emulator
- open a shell or a "command window"
cd
to the apk folder
Then :
- On Windows run
gradlew installDebug
. - On Linux run
./gradlew installDebug