Open GoogleCodeExporter opened 8 years ago
SOLVED
Short Answer: You need to use the Android Native Development Kit (NDK) to
compile a native shared library, which will be included in the Android
Application Package.
Long Answer:
1) Download and install the NDK (you will also need Cygwin if using Windows).
2) I suggest you compile, build, deploy and run at lest the hello-jni sample to
test the install and learn the tools.
2a) Optional, if using Eclipse, install the XML and C/C++ plug-ins (Web Tools
and CDT) if you plan on using the NDK to develop native code.
3) Basicly, follow the instructions in part "III. NDK development in practice"
from OVERVIEW.TXT in the NDK docs:
3a) Make JNI directory under /OpenGLdemos
3b) Copy math.c to the JNI directory.
3c) Copy Android.mk from the <NDK>/samples/hello-jni/jni
3d) Edit Android.mk as follows:
LOCAL_MODULE := opengl-math
LOCAL_SRC_FILES := math.c
4) Compile and Build the same way you did for hello-jni
Additional Notes:
If Eclipse gives you "Build Path" errors, go to "OpenGLdemos->properties->Java
Build Path->Order and Export". Make sure "Android 1.5" is UN-CHECKED and
listed LAST. Why? I have no idea, but it fixed it.
In your java file(s) You must explicitly load the shared library and prototype
the library routines using the 'native' keyword. See common/GlMatrix.java
The library created is actually named lib<LOCAL_MODULE>.so, but the package
manager deals with it for you.
By default, native code is compiled using 16-bit "thumb" instructions. Set the
"Module-description variable"
LOCAL_ARM_MODE := arm
in Android.mk to force the compiler to use 32-bit "arm" instructions. I saw a
noticeable performance gain on my MOTO Droid! (See the file ANDROID-MK.TXT for
details)
Development Tools:
Eclipse 3.5.2
Android SDK r6
ADT 0.9.7
USB Drivers r3
NDK r4 (+Cygwin)
Cheers!
-RWZ
Original comment by robert.z...@gmail.com
on 6 Jul 2010 at 7:29
Original issue reported on code.google.com by
kevingra...@gmail.com
on 30 Jun 2010 at 7:17