Thursday, September 29, 2011

Android NDK

After a lot of googling, and going through some tutorials i could finally setup theAndroid NDK(Native Development Kit) on my machine and successfully compiled a C code, generated the library and ran the code on emulator.

I would like to post some issues that i had to go through while setting up the environment for compiling C code on Windows. Despite of the step-by-step procedure given here
http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/    and
http://www.pocketmagic.net/?p=1332
the cygwin setup was quite confusing for me.

Cygwin is a utility that provides Linux environment on windows, which is required to compile the C code into a library that is used by Android through jni(java native interface). To setup Cygwin go to the link and download setup.exe. Run the exe and check  to install from internet, after that set the directory where setup will be installed as C:\cygwin(recommended), store the installation files at some safe place for further use D:\cygwinInstallationFiles. A list of Packages will appear in that choose Devel package and in that select make:The GNU version of 'make' utility'.

After completing the installation, go to the directory where cygwin is istalled(C:\cygwin) open the Cygwin.bat using a text editor and paste the following code there

@echo off

set IS_UNIX=
set DEV_ROOT=D:/Work/AndroidNDK/NDK_Demo
set JAVA_HOME=C:/Program Files/Java/jdk1.6.0_01
set CLASSPATH=D:/Work/AndroidNDK/NDK_Demo/obj
set PATH=D:/android-sdk-windows/SDK/tools;D:/android-ndk-r5/android-ndk-r6b-windows/android-ndk-r6b
set ANDROID_NDK_ROOT=/cygdrive/D/android-ndk-r5/android-ndk-r6b-windows/android-ndk-r6b
set NDK_PROJECT_PATH=/cygdrive/D/Work/AndroidNDK/NDK_Demo

C:
chdir C:\cygwin\bin
bash --login -i

DEV_ROOT represents your current project's working directory(in my case it is NDK_Demo)
The project must be organized as follows:
A) The JNI part (the .c and .h and Android.mk files) in:
D:/Work/AndroidNDK/NDK_Demo /jni
B) The JAVA part (assets,bin,gen,jni,libs,obj,res,src with the .java files) in:
D:/Work/AndroidNDK/NDK_Demo
For these paths always use forward slashes.

Save the file.

Now we come to making the Android.mk file, create a file Android.mk in the jni folder and paste the following code

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# Here we give our module name and source file(s)
LOCAL_MODULE := demo
LOCAL_SRC_FILES := demo.c

include $(BUILD_SHARED_LIBRARY)

Finally Run the cygwin.bat file by double clicking it. and navigate to your project folder as shown in fig



Type ./ndk-build to compile the JNI project.
The C files have been successfully built. Now using Eclipse, you can build the Java android project, and it will include the JNI part automatically. Easy.

Hope to come back soon with some development about MAC(iPhone).




Saturday, September 17, 2011

My new machine!!!!!!!!


Finally after a long wait I have my new machine on my desk.
For long I had to face the dilemma of choosing the processor between Intel and amd, and in the end amd won the battle.
Amd packs in all the important features that Intel does that too at a considerably lower price. Thus in the price to performance ratio amd wins.
But it is said that amd processors heat up quickly and so need good cooling, as of now I cannot comment on this, although one thing I can say is I am very happy with the performance till now.

Configuration I came up with………

AMD Phenom II X4 965 Black edition 3.4 Ghz
Asus motherboard M5A88 M EVO
LG 22” LED monitor E2260V
WD 500 GB
Transcend 4Gb DDR3 1333MHZ RAM
280W PSU
LG DVD Writer

I have installed virtual MAC Snow Leopard on it and soon will be starting iPhone development on it and I hope that everything just works fine.