Mobile Development on Galaxy S and Galaxy TAB
Native code and Eclipse
Using the Android NDK we can leverage native code for sections of code that require high performance.
Install necessary components:
1. Download NDK (I downloaded r5b)
2. Download cygwin (when installed cygwin you only need to select “make” under the “develop” section… no need to install everything!)
3. Install CDT module in Eclipse (for C++ development).
4. I also added a reference the “cygwin\bin” folder and the “android sdk folder” to the PATH.
Change app to also support C++:
1. Open app as per usual in Eclipse
2. Right-click on the project and then “New -> Convert to C/C++ project”, and then select “Makefile project with Other Toolchain”.
3. Add the references to the android include locations
– Navigate to C/C++ General -> Paths and Symbols.
– For both C and for C++ remove all built-in include paths. You will need the following three
Create build procedure for NDK:
1. Create NATIVE builder
– Right click on your project, pick properties.
– Select “builders” from the left-hand list.
– Click “New…” on the right side.
– Select “Program” as the configuration type.
– Change the name to “Native Builder”
>> Location: [CYGWIN PATH]\bin\bash.exe
>> Working Directory: [CYGWIN PATH]\bin
>> Arguments: See bottom of post for this info
– Now go to the refresh tab
>> Check “Refresh resources upon completion”
>> Select “Specific resources”
>> Click on the “Specify resources” button and select your project’s lib directory.
>> Check “Recursively include sub-folders”
– Now go to the build options tab
>> Check “Allocate Console”
>> Check “Launch in background”
>> Check “Run the builder After a Clean”
>> Check “Run the builder During manual builds”
>> Check “Run the builder During auto builds”
>> Check “Specify working set of relevant resources”
>> Click on “Specify Resources”: Select your project’s JNI directory and all files within.
– Now click OK on the bottom.
2. Change BUILD behaviour
– Go to Properties -> C/C++ Build -> Builder settings
– Choose the Behavior tab (Properties -> C/C++ Build again)
– Remove target names from both “Build” boxes. Leave clean target for the third build type (Clean).
[CYGWIN PATH] = Your cygwin path
[NDK_PATH] = Your NDK path
–login -c “cd /cygdrive/[App JNI folder] && /cygdrive/[NDK_PATH]/ndk-build"
App path = c:\android_dev\test
Ndk path = c:\android-ndk-r5b
–login -c "cd /cygdrive/c/android_dev/test/jni && /cygdrive/c/android-ndk-r5b/ndk-build"