If you appreciate this project, support me on Patreon !
This example demonstrates how to :
- assemble a library written with the ARMv8-A 64 bits GNU ASsembly syntax
- call a native procedure, defined in this library, from a Android app using the JNI
- display the value returned by this native procedure in the Android app
- GNU AS (aarch64)
- Gold linker (aarch64)
- 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="aarch64-linux-gnu-"
export DEST="./apk/app/src/main/jniLibs"
$PREFIX-as -o wild.o wild.s
$PREFIX-ld.gold -shared --dynamic-linker=/system/bin/linker -shared --hash-style=sysv -o libwildAssembly.so wild.o
mkdir -p $DEST/arm64-v8a
cp libwildAssembly.so $DEST/arm64-v8a/libwildAssembly.so
- The Android NDK path in your system's PATH directory
Open a shell or a command window in this folder and :
- On Windows, run 'mkbuild'
- On Linux, run 'mkbuild.sh'
- Connect your ARMv8-A 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
Connect your ARMv7 Android phone/emulator and run ./gradlew installDebug
from the apk folder.