Green Galaxy

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.

I used a combination of the info in here and here to get the latest NDK integrated with Eclipse.

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

Builder arguments:
–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"

Setup Development Environment

My android development is done using Eclipse as the development IDE.

To install and setup Eclipse I followed the steps outlined here.

It is important to note that the Eclipse version that should be downloaded is the “Eclipse IDE for Java EE Developers”.
This is a larger download but includes a lot of additional modules that are needed for the “Android modules”.
I had issues getting the Android modules working with the standard edition due to lots of missing dependencies.

Updating to Froyo

Here in South Africa we have a problem with Froyo updates for the Galaxy S.
Both the network operators and Samsung locally are now silent on all the issues.
With a “branded” firmware currently running on my phone I was left with to option but to “make ‘n plan”.

Below is the process that I used – obviously I will not accept any responsibility for any damage/bricking to your phone – but you are welcome to try it. So far I have tried on 2 phones with 100% success rate.

    1. Check CSC version.

  • This is done by “dialing” the following number: *2767*4387264636#
  • You will then know what version of firmware you are using: XFA or XFV or XFM etc.
    2. Set new market CSC

  • This is done by “dialing” the following number: *#272*[current 24 hour time]#
  • eg. At 19h55 you need to type in *#272*1955#
  • Then select XFA… device is wiped and set to XFA device settings.
    4. Download terminal app from Market

  • Open up the market and search for “terminal emulator”
    6. Terminal:

  • Open up the terminal that was downloaded in the previous steps and then run
  • su
  • chmod 777 /efs/nv_data.bin
  • mv nv_data.bin nv_data.bin.backup
  • mv nv_data.bin.md5 nv_data.bin.md5.backup
    7. Upload edited product code info

  • Use ADB.exe from the command prompt (in rar from Step4) to copy off nv_data.bin: adb push nv_data.bin /efs
    8. Terminal:

  • Open up the terminal that was downloaded in the previous steps and then run
  • su
  • chmod 755 /efs/nv_data.bin
  • chown /efs/nv_data.bin (or chown 1001.1001 /efs/nv_data.bin)
    9. Check new CSC version.

  • This is done by “dialing” the following number: *2767*4387264636#
  • This should now say XFA
    10. KIES.

  • Plug in to PC and update using KIES

Blog relaunch

Blog has been relaunched