Skip to content

Miouyouyou/ARMv7-Java-JNI-return

Repository files navigation

Pledgie ! Tip with Altcoins

About

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
  • use the returned value in the Android app and display it

Building

Building using GNU Make

Requirements

  • GNU AS
  • Gold linker
  • An ARM Android phone/emulator on which you have installation privileges

Build

Run make from this folder

Manually

Run the following commands :

# cross compiler prefix. Remove if you're assembling from an ARM machine
export PREFIX="armv7a-hardfloat-linux-gnueabi"
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
cp libwildAssembly.so $DEST/armeabi/libwildAssembly.so
cp libwildAssembly.so $DEST/armeabi-v7a/libwildAssembly.so

Building using Android ndk-build

Requirements

  • The Android NDK path in your system's PATH directory

Build

Open a shell or a command window in this folder and :

  • On Windows, run 'mkbuild'
  • On Linux, run 'mkbuild.sh'

Installing the prepared APK

  • 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

Install

Connect your ARMv7 Android phone/emulator and run ./gradlew installDebug from the apk folder.