|
How to make a native c application on Android using NDK?
First, download Android SDK, NDK, Eclipse and follow the instruction on NDK page. Make sure that you installed the development environment correctly.
Make an Android project with Eclipse (check our previous posts). Inside your project folder make a jni folder: <project>/jni/
Then write your c code, here is an Hello Android exemple:
#include <stdio.h>
int main()
{
printf ("hello Android \n");
return 0;
}
Then make an Android makefile: Android.mk inside jni folder:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := test.c
include $(BUILD_EXECUTABLE)
Open a terminal, go to your project folder, type: ./ndk-build
You should have an executable file at your_project/bin/ndk/armeabi/
Use adb to copy this file to emulator:
./adb push /path_to_your_project/bin/ndk/local/armeabi/test data
adb shell data/test
Then you should see "Hello Android" on your screen.
Or you can try to open a terminal on the emulator, then go to the folder data, then type ./test, you should see "Hello Android" on the emulator's screen also.
|
How to use custom de...
lets say i change this app to days to...
How to display a JPG...
Is that posible to zoom in and drag p...
Making a custom Andr...
Cool - I will use it carefully i promise
How to display a JPG...
problem in image loading - i have exe...
Introducing Calculon...
Thank You for your contribution - Hi,...