I followed the steps for NDK installation in linux and ran an NDK project .
Initially it was a little tough but now that I am aware of the mistakes I made , I want to share them with all of you ..
here is a step by step procedure on how to install NDK and run a program on eclipse

Installing NDK and running an application developed in NDK with Eclipse
Steps for installation
1)Installing NDK is relatively simple compared to SDK. Extract the contents of the NDK folder.
Go to build , and run .host-setup.sh . If you are facing issues , you can try sh build/host-setup.sh
Prior to this do update the path of NDK in /etc/bashrc
( source bashrc)
and in the NDKroot directory
declare -x ANDROID_NDK_ROOT /<NDK-home>
2)After installation , go to eclipse and create a new project helloNDK .
Create an activity as follows .
public class newNDK extends Activity {
TextView txtHello;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//obtain a reference to our textview control
txtHello = (TextView) findViewById(R.id.text);
// To invoke our native method
String hello = sayHello();
//update our textview control
txtHello.setText(hello);
}
// This is our native method. This is needed by the "javah" tool
//for generating our .h include header.
public native String sayHello();
//Our static initializer which will load our shared library
//into our classloader/VM
static {
//your library will typically be called "libnewndk.so"
//on Linux, but by convention the "lib" prefix, and ".so"
//suffix are omitted
System.loadLibrary("newndk");
}
}
3)Save this project .
4)Create the .h file by giving the following command in the project home directory.
javah -o newndk.h -classpath bin com.newNDK.newNDK
5)Go to the NDKroot home and create two folders as follows
$mkdir -p $NDK_HOME/sources/hellondk
$mkdir -p $NDK_HOME/apps/hellondk
1.Go to /sources/hellondk
Copy the created newndk.h file from the project home directory to /sources/hellondk
The generated newndk.h file looks like this
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_newNDK_newNDK */
#ifndef _Included_com_newNDK_newNDK
#define _Included_com_newNDK_newNDK
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_newNDK_newNDK
* Method: sayHello
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_newNDK_newNDK_sayHello
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
2.Create a newndk.cpp in as follows
#include <newndk.h>
JNIEXPORT jstring JNICALL Java_com_newNDK_newNDK_sayHello(JNIEnv *env, jobject obj){
return env->NewStringUTF("Hello, NDK!");
}
3.Now create a new Android.mk in /sources/hellondk as follows
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#I Like to build my shared libs using C++
LOCAL_DEFAULT_CPP_EXTENSION := cpp
LOCAL_MODULE := newndk
LOCAL_SRC_FILES := newndk.cpp
include $(BUILD_SHARED_LIBRARY)
4.Now go to /apps/newndk and create Application.mk as follows
APP_PROJECT_PATH := ~/workspace.android/newNDK
APP_MODULES := newndk
5. Now make this project in NDK by going to the NDK root and giving make APP=newndk
This will generate the .so library file after compilation
The following message will be displayed
Compile++ thumb: newndk <= sources/newndk/newndk.cpp
SharedLibrary : libnewndk.so
Install : libnewndk.so => ~/workspace.android/newNDK/libs/armeabi
6.Now go to eclipse ddms , push the shared library file libnewndk.so from ~/workspace.android/newNDK/libs/armeabi to data / project package/lib
This can alternatively be done through adb shell prompt in the sdk-home/tools also but the above method is easier.
7. Now run the application in eclipse and it will run like any SDK developed application but now with a loaded shared library created in NDK


