Beginning android NDK in Ubuntu 10.04 – 12.04
I will describe here the basic steps to start playing with the NDK. This is only an introduction.
the NDK (Native development tool-kit) will allow you to integrate your C/C++ code in your Android apps. I will not discuss here when and and why it is better to use Java code instead of native code, that’s up to you and depends on each project.
You must have your development environment set up, if not you can find instructions here.
Download the NDK from
http://developer.android.com/tools/sdk/ndk/index.html
Once downloaded extract it wherever it is most suitable for you for example in the home folder.
Add the NDK folder to PATH:
in the terminal
cd android-ndk-rb8 (folder name may vary)
echo "export PATH=$(pwd):\${PATH}" >> ~/.bashrc
Now I have found using the command line tools easier than eclipse. Here is how you can try the first sample:
cd
cd ADROID_NDK/samples/hello-jini
android update project -p .
ndk-build (build native code)
ant debug install (install on device or emulator so you must have one of them available)
now you can either search for the app icon on the device or do the following:
adb shell
- am start -a android.intent.action.MAIN -n com.android.your_package/com.android.your_package.YourActivity
You will see there are other samples in the folder that can help you to understand how the NDK works
rv 9:40 am on February 28, 2013 Permalink |
This is what the error is whenever I try to build an example from the samples in adnroid-ndk-r8d. I am working on ubuntu.How to resolve it. Please suggest.
Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile thumb : hello-jni <= hello-jni.c
Assembler messages:
Fatal error: invalid -march= option: `armv5te'
make: *** [obj/local/armeabi/objs-debug/hello-jni/hello-jni.o] Error 1
Brad 5:56 pm on May 6, 2013 Permalink |
Hi RV, I also had the same problem, I found out that you need to extract the tarball with the command line instead of with the built-in archive manager program. For some reason the built in program does not extract some directories properly. Just put the tar.gz into your home directory and then use the “tar -jxf ” on the command line to extract it right from there. Then it should work. It fixed it for me.
See http://code.google.com/p/android/issues/detail?id=41187