jni

Put your problem here if it does not fit any of the other categories.

jni

Postby nuetronprotron » Tue Jan 10, 2012 10:34 am

hi guys,
can anyone has a tutorial or guidance on how to use jni in android to access the native components in android.
I donot have idea about it,it would be great in helping in this thing.
nuetronprotron
Developer
Developer
 
Posts: 37
Joined: Tue Jan 10, 2012 10:22 am

Top

Re: jni

Postby Phyll » Tue Jan 10, 2012 3:24 pm

Hi neutronprotron,

Here is a place that tells you how to get started:

http://mobile.tutsplus.com/tutorials/an ... -tutorial/

Here are my notes on doing it on Windows:

Compiling NDK code with CygWin

If you decide to add native code to your project. Here's briefly how to compile the c/c++ files. You
seem to have to know a lot of stuff about Linux. Sort of like entering a time machine as Cygwin's
command line greets you. By the way, on Windows, Cygwin is necessary.

Make sure your ndk directory is very close to the root (c:\) and has no spaces in the path to it.
Place your entire Android project in the ndk directory. Example: c:\ndk\projectdir
Place the necessary c source files in a folder called jni along with the make file for this code
in a file called Android.mk in the same folder which should contain something like this:

LOCAL_PATH := $(call my-dir)
#LOCAL_PATH := ./jni alternative path
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := first
LOCAL_SRC_FILES := source_code_filename.c
include $(BUILD_SHARED_LIBRARY)

Start CygWin and set the environment string to use cygwin's make.exe.
Mine is like this: export GNUMAKE=/cygdrive/c/cygwin/bin/make.exe
Navigate to project by entering this: cd /cygdrive/c/ndkdir/projectdir
Use the path to the ndk-build executable to build the native code.
Mine is like this: /cygdrive/c/ndk/ndk6/ndk-build
If you get an error check all spelling and caps till you find something wrong.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: jni

Postby nuetronprotron » Wed Jan 11, 2012 4:53 am

hi Phyll,
Thanks alot,it is something that i am looking for and i will go into it.
nuetronprotron
Developer
Developer
 
Posts: 37
Joined: Tue Jan 10, 2012 10:22 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 8 guests