Android requires that all applications be packaged up into an . apk and signed with a digital certificate before it will consider running them. This is true for the emulator and for your personal testing devices, but it's especially true for programs that you want to publish on the Market.

"But wait," you say, "I haven't been packaging or signing anything up to now." Actually, you have. The Android SDK tools have been secretly building and signing everything using a certificate that Google created using a known alias and password. Because the password was known, you were never prompted for it and probably never even knew it existed. However, the debug certificate cannot be used for applications in the Market, so now it's time to take off the training wheels and make your own certificate.

There are two ways to do it: by hand with the standard Java keytool and jarsigner commands5 or automatically with Eclipse. I'm just going to cover the Eclipse way.





right-click the project in the package Explorer, and select Android Tools > Export Signed Application Package. The wizard will guide you through the process of signing your application, including creating a new keystore and private key if you don't already have them. You should use the same key for all versions of all your applications and take the appropriate precautions for preventing your private key from falling into the wrong hands.

Note: If you use the Google Maps API (see Section 8.3, Embedding a MapView, on page 172), then you'll need to get a new Maps API key from Google because it is tied to your digital certificate. Export the program once, obtain a new Maps API key using the online instructions,6 change your XML layout file to use the new key, and then export the program again.

When you're done, you'll have an .apk file that is ready for publishing.

0 0

Post a comment