
- •Contents
- •Acknowledgments
- •Preface
- •What Makes Android Special?
- •Who Should Read This Book?
- •Online Resources
- •Fast-Forward >>
- •Introducing Android
- •Quick Start
- •Installing the Tools
- •Creating Your First Program
- •Running on the Emulator
- •Running on a Real Phone
- •Key Concepts
- •The Big Picture
- •Building Blocks
- •Using Resources
- •Safe and Secure
- •Android Basics
- •Designing the User Interface
- •Introducing the Sudoku Example
- •Designing by Declaration
- •Creating the Opening Screen
- •Using Alternate Resources
- •Implementing an About Box
- •Applying a Theme
- •Adding a Menu
- •Adding Settings
- •Starting a New Game
- •Debugging
- •Exiting the Game
- •Exploring 2D Graphics
- •Learning the Basics
- •Adding Graphics to Sudoku
- •Handling Input
- •The Rest of the Story
- •Making More Improvements
- •Multimedia
- •Playing Audio
- •Playing Video
- •Adding Sounds to Sudoku
- •Storing Local Data
- •Adding Options to Sudoku
- •Continuing an Old Game
- •Remembering the Current Position
- •Accessing the Internal File System
- •Accessing SD Cards
- •Beyond the Basics
- •The Connected World
- •Browsing by Intent
- •Web with a View
- •From JavaScript to Java and Back
- •Using Web Services
- •Locating and Sensing
- •Location, Location, Location
- •Set Sensors to Maximum
- •Putting SQL to Work
- •Introducing SQLite
- •Hello, Database
- •Data Binding
- •Using a ContentProvider
- •Implementing a ContentProvider
- •3D Graphics in OpenGL
- •Understanding 3D Graphics
- •Introducing OpenGL
- •Building an OpenGL Program
- •Rendering the Scene
- •Building a Model
- •Lights, Camera, ...
- •Action!
- •Applying Texture
- •Peekaboo
- •Measuring Smoothness
- •Fast-Forward >>
- •The Next Generation
- •Multi-Touch
- •Building the Touch Example
- •Understanding Touch Events
- •Setting Up for Image Transformation
- •Implementing the Drag Gesture
- •Implementing the Pinch Zoom Gesture
- •Hello, Widget
- •Live Wallpaper
- •Write Once, Test Everywhere
- •Gentlemen, Start Your Emulators
- •Building for Multiple Versions
- •Evolving with Android APIs
- •Bug on Parade
- •All Screens Great and Small
- •Installing on the SD Card
- •Publishing to the Android Market
- •Preparing
- •Signing
- •Publishing
- •Updating
- •Closing Thoughts
- •Appendixes
- •Bibliography
- •Index

Chapter 14
Publishing to the Android Market
Up to now you’ve just been creating software to run in the emulator or to download to your personal Android phone. Are you ready to take the next step? By publishing to the Android Market,1 you can make your application available to millions of other Android users. This chapter will show you how.
14.1Preparing
The first step of publishing an application to the Market is, well, to write the application. See the rest of the book for directions on how to do that. But simply writing code is not enough. Your program needs to be of a high quality, free of bugs (yeah right), and compatible with as many devices as possible. Here are a few tips to help you:
•Test it on at least one real device before letting anyone else see it. If you forget all the other tips, remember this one.
•Keep your program simple, and polish the heck out of it. Make your program do one thing well, rather than a lot of things poorly.
•Pick a good Java package name, such as com.yourcompany.progname, that you can live with for a long time. Android uses the package name defined in AndroidManifest.xml as the primary identifier for your application. No two programs can have the same package name, and once you upload a program to the Market with that name, you cannot change it without completely removing it, requiring all users to uninstall, and publishing a new program.
1. http://market.android.com

SIGNING 272
•Pick a meaningful value for android:versionCode= and android: versionName= in your AndroidManifest.xml file.2 Consider future updates, and leave room for them in your naming scheme.
•Follow the Android best practices,3 such as designing for performance, responsiveness, and seamlessness.
•Follow the user interface guidelines,4 such as icon design, menu design, and proper use of the Back button.
Compatibility with multiple devices is one of the toughest challenges facing the Android programmer. One issue you’ll have to deal with is users having different versions of the platform installed on their phones. See Chapter 13, Write Once, Test Everywhere, on page 256 for advice.
Although first impressions and compatibility are important, you’ll need to strike a balance between tweaking and polishing your application to make it perfect vs. releasing it in a timely fashion. Once you think it’s ready, the next step is to sign it.
14.2Signing
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.
2. http://d.android.com/guide/publishing/versioning.html
3.http://d.android.com/guide/practices/design
4.http://d.android.com/guide/practices/ui_guidelines
5.http://d.android.com/guide/publishing/app-signing.html

PUBLISHING 273
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.
14.3Publishing
The Android Market is a Google-hosted service you can use for posting all your programs. To get started with publishing, you first need to sign up as a registered developer on the publisher’s website (also known as the Developer Console).7 There is a small registration fee.
As an additional step, if you want to charge for your program, you’ll need to sign up with a payment processor. The publisher’s website will instruct you on how to do that. As of this writing, only Google Checkout is supported, but in the future, other processors such as PayPal may be supported.
Now you’re ready to upload. Click the Upload Application link, and fill out the form. Here are three tips:
•Turn Copy Protection off. Android’s copy protection is completely insecure and performs no useful function other than to irritate your users.
•Unless you have a reason not to, set the Locations option to All Current and Future Countries. New countries are being added all the time, and this way your application will be available to all of them.
6. http://code.google.com/android/add-ons/google-apis/mapkey.html
7.http://market.android.com/publish

PUBLISHING 274
•Do not supply your phone number in the application Contact Information. All Market users will be able to see this number, and they will call it when they have problems. Of course, if you have a dedicated number and staff for phone support, then this tip doesn’t apply.
Just to give you an example, here’s how I filled out the form for an application I published called Re-Translate Pro (an updated version of the translate example from Section 7.4, Using Web Services, on page 147):
Application .apk file: (select Browse and Upload) Language: English (en_US)
Title (en_US): Re-Translate Pro Description (en_US):
Re-Translate translates a phrase from one language to another and then back again so you can make sure you're saying what you meant.
Try the Lite version to see if you like it first.
Features:
-Translates instantly as you type
-Long press for copy/paste
-Directly send SMS/Email
Application Type: Applications
Category: Tools
Price: USD $1.99
Copy Protection Off
Locations All Current and Future Countries with Payment
Website: http://www.zdnet.com/blog/burnette
Email: ed.burnette@gmail.com
Phone: (blank)
When you click the Publish button, your application will appear immediately on the Android Market on all applicable devices. That’s right, there is no approval process, no waiting period (other than a few seconds to update the download servers), and no limits to what you can do in your programs. Well, almost. You still have to follow the Android Content Guidelines.8 Failure to adhere to the guidelines could result in your application being removed from the Android Market. Among other things, the guidelines say that your content must not be illegal, be obscene, promote hate or violence, or be unsuitable for anyone younger than 18 years of age. In addition, it must not knowingly violate
8. http://www.android.com/market/terms/developer-content-policy.html