Android projects that have native support build the native components along with those rest of the project.
At build time the Sequoyah Android feature compiles the native (C/C++) code into a shared library and then includes
that shared library in the project APK.
You must have configured your development environment to allow native development before you can add native
support to a given Android project.
-
You add native support to an existing Android project. If you are running MOTODEV Studio for Android you
also have the option to add it when you first create the project.
- If you are running MOTODEV Studio for Android and have not yet created your project, do so with
, and at the bottom of the New Android Project dialog select the
Add native support option.
- If you are running Eclipse and have not yet created your project, create it as you normally would, and
then add native support as detailed in the next option.
- If your project already exists, right-click it in the Package Explorer and select . In the
dialog that appears, verify the Library name field and click Finish. The Library name is the base name of the native shared library
that will be created when your app is built (the full name of the library will have a "lib" prefix and an
extension of ".so").
After adding native support your project will now have a "jni" directory with a makefile (Android.mk) and one or more .cpp files; this directory is where you do your
native development. When your project builds you will find the native shared library in your project's
libs/armeabi directory.
You can now create your C/C++ code (in the jni directory); you will likely want to switch to the C/C++
perspective to do this. When you build your project the native code is compiled into the shared library which is
then included as part of your APK. Also note that you will need to load your native library from your Java code by
calling System.loadLibrary(). See the sample applications that are included with the Android NDK
for tips on how and when to do this.