Thursday, November 11, 2010

obfuscation : how to use the obfuscation in the android app development cycle

This post deals with how the new obfuscation step modifies the app development cycle.

I use Eclipse to develop my app (Track Site). After some upgrade, when the app is ready to go live, I usually do the following tasks in order to publish it on the Android Market :
  1. adjust the version number
  2. export an unsigned version of the app from Eclipse
  3. sign it using the standard jarsigner tool
  4. align it using the standard zipalign tool

Obfuscation, as explained in Proguard, Android, and the Licensing Server, involves additional steps that replace the former 2) to 4) steps :
  1. adjust the version number the same way you've done it before
  2. obfuscation is performed using ant (not Eclipse) by issuing a command on the terminal

    mac:TrackSites $ ant release
    Buildfile: ~/workspace/TrackSites/build.xml

    As indicated in the Proguard, Android, and the Licensing Server post, the local.properties file has been modified to perform the signing step [3)] automatically (it still asks you for the passwords though), as well as the alignment one [4)].

    You end up with a signed, aligned and obfuscated app file in the bin/ sub-directory : the app is named SiteListActivity-release.apk. Exporting the unsigned app from Eclipse generates an app file named TrackSite.apk.

    It's interesting to note that the obfuscation process is done in another hierarchy (bin/classes) than the one used by Eclipse (bin/).

  3. as the obfuscation may have broken things, there is another quality assurance phase of the obfuscated app (SiteListActivity-release.apk), not of the non-obfuscated app that has already been tested from Eclipse (TrackSite.apk)

    This should be done :
    a) on the emulator :
    • start the emulator in the background with an AVD as a parameter
      mac:TrackSites $ emulator -avd a8w480 -wipe-data &
      [1] 536
      2010-11-11 10:14:15.172 emulator[491:903] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.


      The -wipe-data option in the command line allows to « Reset the current user-data disk image (that is, the file specified by -datadir and -data, or the default file). The emulator deletes all data from the user data image file, then copies the contents of the file at -inidata data to the image file before starting. ».

      Here is the emulator state when it is started without the -wipe-data option
      And it's state with the -wipe-data option

      The list of devices + emulators connected to the computer is obtained with
      mac:~ $ adb devices
      List of devices attached
      HTxxxxxxxxxx device <----- the real device emulator-5554 device <----- the emulator

    • install the obfuscated app (SiteListActivity-release.apk) on the emulator using adb command line tool
      mac:TrackSites $ cd bin
      mac:bin $ ls Site*
      SiteListActivity-release.apk SiteListActivity-unsigned.apk
      SiteListActivity-unaligned.apk SiteListActivity.ap_
      mac:bin $ adb -e install SiteListActivity-release.apk
      1340 KB/s (94595 bytes in 0.068s)
      pkg: /data/local/tmp/SiteListActivity-release.apk
      Success
      mac:bin $

      The -e option in the command line « direct an adb command to the only running emulator instance. ».

      The app is now installed in the emulator where it can be tested :

    b) on a real device : it's pretty much the same process as above but on a real device instead of an emulator.

    When installing the app on the device, you may encounter an error if a previous version of the app has been installed from the market :
    mac:bin $ adb -d install SiteListActivity-release.apk
    821 KB/s (94595 bytes in 0.112s)
    pkg: /data/local/tmp/SiteListActivity-release.apk
    Failure [INSTALL_FAILED_ALREADY_EXISTS]
    mac:bin $

    By the way, please take note of the -d option in the command line « direct an adb command to the only attached USB device. ».

    The solution here is to remove the app on the device : Menu -> Settings -> Applications -> Manage applications then select the application to uninstall, click on the "Uninstall" button, confim ... it works ! But there's a better solution using adb :
    mac:bin $ adb -d uninstall fr.androidtobe
    Success
    mac:bin $


    You can now try to install just like before :
    mac:bin $ adb -d install SiteListActivity-release.apk
    839 KB/s (94595 bytes in 0.110s)
    pkg: /data/local/tmp/SiteListActivity-release.apk
    Success
    mac:bin $

  4. Ensure everything works and that the obfuscation has not broke anything. Then publish the obfuscated app (SiteListActivity-release.apk).

    If something has been broken during the obfuscation step, look for clues in the « But Wait, My App is Crashing Now » part of the Proguard, Android, and the Licensing Server post

Tuesday, November 9, 2010

HTC Desire HD - the permanent root with [DEV] PERMROOT & eMMC write [INSTRUCTIONS]

A permanent root solution has been found for the HTC Desire HD. Detailled instruction are in the XDA-Developers post [DEV] PERMROOT & eMMC write [INSTRUCTIONS].

Nexus One : how to prepare for Gingerbread

The next release of Android, Gingerbread, is rumored to be OTA released in the coming days. Android Central, working with XDA-Developers wiki comes with a welcomed [How-to] Prep Nexus One for Gingerbread

« If you're like us, and have your Nexus One hacked nine ways to Sunday, you'll need to get ready if you don't feel like waiting for someone to rip it apart and whip up a version for the rooted and ROM'd crowd. »

Saturday, November 6, 2010

Nexus One - installing [ROM] Enomther's TheOfficial Nexus1 - v2.13.2 - 10/11/2010

I've decided to give a try to [ROM] Enomther's TheOfficial Nexus1 - v2.13.2 - 10/11/2010.

The Nexus state before installing Enomther's TheOfficial ROM :


Here are the detailled steps to install it on a rooted Nexus One.
  1. connect the Nexus to your computer using the USB cable
  2. download the resources and check the md5
  3. copy the files to the SD card.
    You can either mount your phone in USB storage mode (recommended) or use adb tool
    The files to be copied to the root of the SD card are :
    • RADIO TheOfficial_Nexus1_Radio_Update_4.06.00.12_7.zip
    • ROM : TheOfficial_Nexus1_v2.13.2_update.zip
    • MUSIC : origmusic_2.12.1.zip
    • CAM : origcam_2.12.3_kernel_audiomod.zip
    • TORCH : CMMod_Torch_2.11.3.apk.apk
    The RADIO TheOfficial_Nexus1_Radio_Update_4.06.00.12_7.zip will be flashed.
  4. make a Nand backup
    • Reboot the Nexus One in bootloader mode : hold down the trackball while you press the power button. Ensure to maintain the trackball hold down until the screens turns to a white screen with 3 green android skating at the bottom of the screen. Ensure that the Nexus One stay connected to the computer via the USB cable.
    • on the screen, the BOOTLOADER should be highlighted with blue. press power button
      on the new screen, scroll down with the Volume down button to highlight the RECOVERY option. Press the power button.
    • the Nexus One reboots and after a few seconds, the screen title with "Android system recovery" appears, with the "Build : RA-nexus-v1.7.0" at the bottom of the screen. The screen should be in cyan instead of green if the Nexus One has already been rooted
    • scroll down with the trackball to the "Backup/Restore" menu and press the trackball
    • on the new screen "Choose backup/restore item" choose the option "Nand Backup" (the first one) by scrolling down the trackball and press the trackball to select it. The question "Create Nandroid backup?" appears at the bottom of the screen, so press the trackball to confirm as it is stated
    • The backup starts, it takes a few seconds to complete. At the end of the backup, the cyan screen is restored. Press Volume down button to return to the previous screen "Android system recovery".
  5. flash the RADIO
    • back to the Android system recovery screen, scroll down to the Flash zip from sdcard item using the trackball. Press the trackball to select
    • on the new screen Choose update ZIP file, use the trackball to select the right ZIP file to flash. Start with the RADIO TheOfficial_Nexus1_Radio_Update_4.06.00.12_7.zip. then press the trackball to start the flashing. Press the trackball again to confirm flashing on the question "Install : TheOfficial_Nexus1_Radio_Update_4.06.00.12_7.zip ?" that appears at the bottom of the screen. The ROM flashing starts and many messages appears on the screen.
    • after some time, the message "Install from sdcard complete" appears and you're asked to reboot the phone to write the image on the phone. Press the trackball to proceed
    • after some time, you're back to the Android system recovery screen
  6. WIPE
    • from the Android system recovery screen, select the WIPE item using the trackball and press it
    • from the new screen "Choose wipe item", highlight the "wipe data/factory reset" item (the first one) and press the trackball once to select it, then press the trackball another time to confirm to proceed as it is asked at the bottom of the screen
    • then redo the same steps for the "Wipe cache", "Wipe Dalvik-cache", "Wipe battery stats", "Wipe rotate settings" but don't wipe the "SD:ext partition"
    • press VOL-DOWN to return to the Android system recovery screen
  7. flash the ROM
    • highlight the "Flash zip from sdcard" item using the trackball and press the trackball to select the item
    • from the "Choose update ZIP file" screen, highlight the "TheOfficial_Nexus1_v2.13.2_update.zip" item and press the trackball to select it. Press the trackball another time to confirm as you're asked to at the bottom of the screen. The flashing starts. At the end of the process, you're back to the Android system recovery screen.
    • follow the same steps to flash the MUSIC origmusic_2.12.1.zip
      and CAM origcam_2.12.3_kernel_audiomod.zip files. The nexus reboots automatically after fashing each of those files.

After flashing the Enomther's TheOfficial Nexus ROM :

Monday, November 1, 2010

Desire HD - rooting and shutdown, restart and fastboot modes

The Desire HD has 3 modes when it comes to shutdown and startup :
  • full shudown : it's the classical way of shutting down Android. All processes are killed and the caches are flushed. After a shutdown, there is a cold start which takes quite a lot of time : about 25s to get the htc logo with the djingle + 40s more to load Android and ask you to enter your PIN code + 25s more to register on the network.

    rooting : After a full shutdown, the temporary rooting needs to be done again, and any package that may have been disabled (see [GUIDE] Disabling Stock/System Apps) has to be disabled again.
  • restart (reboot) : it's also a classical way to restart Android that takes approximately the same time the full shutdown process takes.

    rooting : After a reboot, the temporary rooting needs to be done again, and any package that may have been disabled (see [GUIDE] Disabling Stock/System Apps) has to be disabled again, like after a full shutdown.
  • fastboot shutdown : this is a new shutdown mode introduced by HTC in its latests smartphones. It basicaly freeze everything (processes, cache, ...) in its state and then has just to unfreeze them to startup. The startup process is then very fast : less than 5s for the phone to ask you to enter your PIN code + 25s more to register on the network.

    rooting : After a fastboot shutdown, the temporary rooting that may exists before the fastboot still exists and does not need to be done again, and any package that may have been disabled (see [GUIDE] Disabling Stock/System Apps) is still disabled. By the way, any app that have been launched before the fastboot is still awake and available through a long press on the Home button.



The power-down screen look like :


The fastboot shudown mode has to be activated from the "Menu" -> "Settings" -> "Applications" -> "Fast boot" checkbox :


The restart option ask for a confirmation :

Sunday, October 31, 2010

"setCPU for Root Users" saves the battery of your Android device

I've used setCPU for Root Users on my Nexus and now on my Desire HD to save battery : setCPU adjusts CPU speed to what is needed to perform the required tasks.



setCPU lets you adjust the lower and upper speed for your CPU. There's a "device selection" function in the menu that lets setCPU perform all the computing and suggest the appropriate values for your hardware. Here's a screenshot for the Desire HD.



The "Time in State" section from the "info" tab lists the time your phone has spent at different speeds. From the following screenshot, it appears the Desire HD CPU speed scales between 4 speeds from 245 MHz to 1024 MHz, spending most of its time between the upper and lower speed. The same screen on the Nexus One shows many different speeds, the Nexus spending most of its time on the lower speed (it naturally depends on how you use your Nexus).



As said in its name, setCPU for Root Users require root access.Rooting instructions can be found here :

Head to setCPU for Root Users's official page to get more informations on setCPU, specially on how to use setCPU to overclock / underclock your CPU.

Scan the following QR-code to download setCPU from the Android Market.

Saturday, October 30, 2010

Desire HD Ace : how to temporary root - [GUIDE] Temp Root [VISIONary by PaulOBrien]

Right now, there's no permanent rooting solution for the new HTC Desire HD (for UK).


But there's a temporary root solution provided by MoDaCo with the VISIONary app available on the Android Market.

Friday, October 29, 2010

HTC Desire HD (Ace)

Just receive my new Android phone : the HTC Desire HD (here in english HTC Desire HD).

Very nice phone.

But still not permanently rooted at the time of this writing.

Track Site : how to backup and restore your bookmarks

Before changing Android phone or making a factory reset, you need to backup your Track Site bookmarks before, in order to restore them on your new Android phone or after the factory reset.


1) Backup the bookmarks

To backup, go to "Menu" --> "More" --> "Backup".



The "track_sites.ini" file is created at the root of the SD card. The backup erase any file with the same name.


2.1) Factory reset

If you just make a factory reset, keeping the same phone, you don't have anything more to do, as long as you don't erase your SD card or format it : proceed with the factory reset, then restore your bookmarks following the instructions of section 3) below.

If you want to change your SD card or format it, you need to keep the backup (the "track_sites.ini" file) in a safe place before changing your SD card or formatting it, and then follow the instructions in the next 2.2) section


2.2) Transfer to a new phone

If you change your Android phone or your SD card or format your SD card, you need to transfer the "track_sites.ini" file from your old phone to the root of the SD card on your new Android phone.

This can be done in 2 ways :
  1. The easiest way (recommended) is by connecting your phone to a desktop computer (PC / Mac / Linux) and mounting it as an USB drive.

    This is direct on Mac.
    You need a driver on Windows.

    You just have to copy the "track_sites.ini" file from your old phone phone to the new one (or to a safe place on your computer if you want to format your SD card or change it).
    Then, unmount or disconnect the new phone from USB in order to be able to access the SD card contents.
  2. Developers can use the adb tool (see 2.2 bis) below).

3) Restore the bookmarks

To restore your bookmarks, go to "Menu" --> "More" --> "Restore"
The "track_sites.ini" file is read from the root of the SD card and it's content is loaded in the Track Site app.

Be aware of not loading the file multiple times as file bookmarks are added to the ones that may already exists.



2.2 bis) The adb (hard) way for the developers

The "USB debugging" option should have been activated on both phones ("Settings" --> "Applications" --> "Development" --> "USB debugging").

The full file path is /mnt/sdcard/track_sites.ini

And here is how to get it and transfer it :
  • a) ensure your phone is available

    mac:~ $ adb devices
    List of devices attached
    xxxxxxxxxxx6 device
  • b) ensure the file is where you think it is

    mac:~ $ adb shell
    # ls -l /mnt/sdcard/tra*.ini
    ----rwxr-x 1 system sdcard_r 30719 Oct 28 12:57 /mnt/sdcard/track_sites.ini
    # exit
    mac:~ $
  • c) then go to the directory where you want to download the file (Downloads in the following example) and pull it

    mac:~ $ cd Downloads/
    mac:Downloads $ adb pull /mnt/sdcard/track_sites.ini
    847 KB/s (30719 bytes in 0.035s)
    mac:~ $
  • d) then connect the new phone as in a).

    Ensure the old phone is disconnected from your system or you end up with 2 devices (2 lines) with the adb devices command.

    mac:Downloads $ adb devices
    List of devices attached
    xxxxxxxxxxx6 device
    yyyyyyyyyyy9 device
    mac:~ $
  • e) remove any /mnt/sdcard/track_sites.ini file from the destination.

    mac:Downloads $ adb -s yyyyyyyyyyy9 shell
    $ ls -l /mnt/sdcard/track_sites.ini
    ----rwxr-x system sdcard_rw 1241 2010-10-29 11:03 track_sites.ini
    $ rm /mnt/sdcard/track_sites.ini
    $ ls -l /mnt/sdcard/track_sites.ini
    /mnt/sdcard/track_sites.ini: No such file or directory
    $ exit
    mac:~ $
  • f) push the track_sites.ini file to its final location /mnt/sdcard/track_sites.ini.

    mac:Downloads $ adb -s yyyyyyyyyyy9 push track_sites.ini /mnt/sdcard/track_sites.ini
    1505 KB/s (30719 bytes in 0.019s)
    mac:~ $

Thursday, October 28, 2010

Nexus One - how to upgrade to CyanogenMod-6.1 V6.1.0-RC1 (10/27/2010) - instructions

I have just installed the CyanogenMod-6.1 first release candidate V6.1.0-N1-RC1 - 10/27/2010 (CyanogenMod-6.1 for Nexus One: Holy crap, it's full of AWESOME! V6.1.0-RC1 (10/27/2010)). Just keep in mind it is the 1st Release Candidate and as such, there are still some issues.

As the required radio image is still radio-4.06.00.12_7.img (Radio Firmware: 4.0.6.00.12_7 (FROYO RADIO, 4.06 OR HIGHER REQUIRED!)), I just have to upgrade to the new CyanogenMod-6.1 6.1.0-RC1.

I slightly depart from Cyanogen's instructions to upgrade :
  1. Do a Nandroid Backup !
    --->> steps 1) to 11) from Nexus One - how to upgrade to CyanogenMod-5 [stable 5.0.6 version of 04/15/2010] - detailled instructions
  2. Wipe : I add this step as it prevents problems with Google Apps ; just remember to save everything before (don't forget to backup your Track Site's data).
    The wipe has to be done while in recovery mode just after the Nandroid backup (the previous step).
    Here are the detailled steps :
    • from the "Android system recovery" screen you are just after the step 11), scroll down to the "Wipe" item using the trackball, press on the trackball to select the item
    • On the "Choose wipe item" screen, choose the "Wipe cache" item (the 2nd one) using the trackball. The "Wipe cache" seems to be enough and does not need to reinstall all applications. Press the trackball a 2nd time to confirm on the question that appears on the back of the screen.
    • The wipe starts and takes a few seconds to complete. At the end of the wipe, the cyan screen is restored. Press Volume down button to return to the previous screen "Android system recovery".
    • follow on with step 14) of the upgrade procedure
  3. Install the CyanogenMod-6.1 6.1.0-N1-RC1 - 10/27/2010 ROM (your Google apps will be backed up automatically)
    --->> steps 14) to 16) from Nexus One - how to upgrade to CyanogenMod-5 [stable 5.0.6 version of 04/15/2010] - detailled instructions. Don't reboot at this time and continue with the step below
  4. There's a 4th step to Cyanogen's instructions to install the most up to date version of Google apps : HDPI-20101025 (UPDATE 11/03 : Google Apps have been made available in a dedicated place : http://goo-inside.me/google-apps/ ; a wiki dedicated to Google Apps have been made available )
    --->> steps 15) and 18) from Nexus One - how to upgrade to CyanogenMod-5 [stable 5.0.6 version of 04/15/2010] - detailled instructions. At the end, just reboot (or power-down by selecting the right option with the trackball in step 17)).

The detailed instructions to follow are pretty much the same as for Nexus One - how to upgrade to CyanogenMod-6 V6.0.0-RC1 (07/11/2010) - instructions to get the 6.1.0-N1-RC1 - 10/27/2010 ROM update-cm-6.1.0-RC1-N1-signed.zip installed.