Create a directory: /jni
and another directory /libs
. Now put your example.c
and your Android.mk
inside the /jni
directory. Now cd
to the /jni
directory and type the command ndk-build
. If your makefile is correct and there are no errors in you source files the under the /libs
directory another new directory called /armeabi
would be created. Inside this directory, your executable would be present.
To execute this executable the android device must be rooted or you can use the android emulator provided with SDK.
Further you need to place this executable into /data/local/
location of your android device (because even though your device is rooted, you will not have execute permissions from other locations.
you can do so using the below command:
adb push example /data/local/
Now enter the adb shell
mode and cd to /data/local/
.
Change your file permissions: chmod example 777
Now in this same location you can place your shell file. Also you can access your sdcard and other folders from this directory.
Hope this is helpful to you. If everything works, don't forget to accept the answer.