Posts Tagged ‘google’

Signing an Android Application for Real Life Mobile Device Usage / Installation

Monday, January 19th, 2009

Android Certificate
If you want to publish an Android application you first need to write it :)

The result of your programming will be an .APK file which is the actual program binary of your application. However, the .APK file your compiler creates can only be used with the emulator on your desktop PC or Mac. You cannot use the same .APK file to install and run your app on your Android phone (like the G1, Kogan Agora, or else).

Why is that? Well, Google wants to protect its phone users from installing and running fraudulent software on their devices. Therefore, each and every application needs to be signed with a valid certificate that ensures where the application comes from. Meaning: the developer (you!) signs the application with his/her certificate to make sure it is always traceable where the application comes from. There are a bunch of more reasons to this so lets check out what Google is saying about this topic:

The important points to understand about signing Android applications are:

  • All applications must be signed. The system will not install an application that is not signed.
  • You can use self-signed certificates to sign your applications. No certificate authority is needed.
  • When you are ready to publish your application, you must sign it with a suitable private key. You can not publish an application that is signed with the default key generated by the SDK tools.
  • The system tests a signer certificate’s expiration date only at install time. If an application’s signer certificate expires after the application is installed, the application will continue to function normally.
  • You can use standard tools — Keytool and Jarsigner — to generate keys and sign your application .apk files.

3 Easy Steps for getting what you need to sign Applications
(this needs to be done once only)

  1. Create a keystore with your own keys and certificates
    First of all you need to create a keystore which stores your certificate. A certificate is always created by the developer himself without any interaction from Google. This actually means that Google does not approve certificates before you can use them for signing your application. (Note: other companies like RIM, Nokia/Symbian, Windows Mobile do such things.)

    Once you installed a Java SDK you can use the default keytool application to create your own keystore. A Java SDK is installed by default on Mac OS X machines and can also be installated additionally on your Windows PC or Linux machine. If you have Java SDK running on your system just go to any prompt and type in the following:

    Windows: START»Command
    $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -validity 10000

    Windows: Mac: Terminal
    $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -validity 10000

    You will be asked to enter a password for your keystore. Choose it wisely and remember it! You will need it every time you sign an APK file. Follow the instructions and finalize the creation of your keystore.

  2. Place the keys at a location that makes sense
    Choosing the right place for your keystore is quite important. Let’s imagine you write more than one application so it would not make that much sense to put this keystore into the project directory of the application you are currently working with. As I am using Mac OS X Leopard and Eclipse I got a project directory like /Users/YOUR_NAME/Documents/workspace/DialANumber. However, as mentioned before a more global approach might make so I copied the keystore to the directory:

    /Users/YOUR_NAME/Documents/workspace/androidkeys

    So we got our keystore prepared for signing now.

  3. Write a short script to make your life easier
    Just to make the life easier I wrote a short script which can be used each time to sign your Android APK file. You can download it below and place it in the same directory you placed the keystore at (see point 2).

    Download: Signing Script for Easy .APK Signing

Once you have done this we are ready for signing our application!

3 Easy Steps for getting your Application signed
(this needs to be done each time you build a binary that is going to be published)

  1. Build your application

    Right click your Android project in Eclipse and select Android Tools » Export Unsigned Application Package.... Follow the instructions and remember the directory your placed the .APK file at. E.g. cd /Users/YOUR_NAME/Documents/workspace/DialANumber/deploy/

  2. Go to your keystore & script directory

    cd /Users/YOUR_NAME/Documents/workspace/androidkeys/

  3. Sign your application
    In your androidkeys directory you need to execute:

    ./sign-mac-example.sh ../DialANumber/deploy/DialANumber.apk
    Enter passphrase:

    After you entered your passphrase the application should be signed.

You can now upload your app to your server and install it on an Android phone or you can even publish it on the Android Market!

Sources:

P.S.: The complete signing process (the part you need to do each time you sign an app) could be integrated better into Eclipse. I hope Google improves this in future. They could add an entry like Android Tools » Export Signed Application Package... so the developer just needs to enter the passphrase in a GUI dialog. This would make everyone’s life much easier. Perhaps a bored Eclipse PlugIn developer might want to write a plugin for this? It would make many people happy I guess :)

How / Where to buy a T-Mobile G1 Google phone in Hong Kong

Friday, November 14th, 2008

The T-Mobile G1 is on sale in the US for about 3 weeks now. It seems to be a quite popular phone and there already appeared some phones on ebay in the US as well as in Europe.

Yesterday I was checking out the Hong Kong mobile phone dealers on the Google / T-Mobile G1 (aka HTC Dream). While Hong Kong is usually quite quick with new products (especially mobile phones) the G1 was not available for a while. The online shopping market is not really existing here at the moment and therefor, it is always good to check out local stores. The two best places in Hong Kong for imported gadget and high end stuff (including gadgets that are never going to be released in other markets because HK is the electronics companies’ playground) are:

So I checked nearly every shop I could find and some of them had the T-Mobile G1 in their showcases. I was even allowed to touch one! 8-)

The G1’s price range in those shops was:

  • Maximum: HK$4980 (~US$642)
  • Minimum: HK$3500 (~US$451)

As you can see there is big difference of nearly US$200 between the offers but the lower price seems to be a good deal. Here are some photos from the good priced one in the shop on Nathan Road:

How to buy a T-Mobile G1 Google phone in Hong Kong

How to buy a T-Mobile G1 Google phone in Hong Kong

As far as I remember it is near Nathan Road no. 123 but I am not that sure. Might be in Burlington House or very nearby.

Android invasion

Friday, October 31st, 2008

I just read this article on the Financial Times site of the FT Techblog:

Tech blog (Richard Waters): I have to confess: Google’s mobile phone platform is getting off to a much better start than I had expected.

The generally favourable reviews of the first Android phone, the G1 made by HTC for T-Mobile, showed how well Google had done from a standing start in just a year and half.

Now comes news that Motorola is about to throw its lot in with Android, using the Google software for its consumer smart-phones. Given Motorola’s slumping market share, it certainly makes sense to consolidate on three platforms.

It’s too early to declare Android a winner, though. Google still has to persuade mobile phone companies that it is friend rather than foe. The T-Mobile device works best as a delivery mechanism for Google’s own services. How many operators are ready to throw their lot in with Google to that degree?
Full text: www.ft.com/techblog

IMHO, Motorola announcing to take a deeper look to the Android platform and supporting it is a quite huge step forward for Android. Not so long ago Motorola was the second largest cell phone maker in the world and it was about to push Nokia from its throne as the world’s larget manufaturer. But since the amazing Motorola RAZR they didn’t do anything special in the market and their products just didn’t have any flair. I still have my Nokia shares in my depot and not Motorola. Nokia is still one step ahead and they have a more innovative flair.

However, I think Google and Android will kick off soon. There just need to be more devices available, more users, more developers and more interest in the platform. Until now Google did a lot of good things and making the platform and free of charge means that manufacturers can build phones with the OS without paying for the OS. This is a huge advantage in point of saving per product costs in the first place. Furthermore, they have the freedom to customize the OS to their needs (say manufacturer / carrier branding, etc.).

Regarding 3rd party applications (that is our field guys!) developers just love open source software. From my point of view not that much that it is mostly available free of charge but it provides the possibility to look into the original source code and get a clue how the heck Google made this or that. I don’t consider this stealing of code. It is just a hint to crash my mental blockade which I guess everyone of you might have experienced some time ago.

Anyhoo, it is getting more and more interesting by every day that passes by. Share your thoughts – share your code – just if you want to, of course! :)

What do you think about that?