views:

243

answers:

2

I have installed a couple of free apps on my Android phone and then later "upgraded" to the paid full version. My first instincts for doing the same would be to create two apps with the same package name so that installing one overwrites the other, but apps in the Market must be unique by package name.

What are some patterns and best practices for sharing code and resources for free and paid versions of the same app and any naming conventions or project structures that work for this scenario as well?

A: 

Each app has to have a different package name, otherwise it's considered an "upgrade". The market is very black and white about this rule (I found out the hard way).

Speaking for myself, I like to see an app on the market in free form, which always remains available and always free. It may lack some features which are presented in a pay version of the app, and I may gladly download the paid app, once I familiarize myself with the free one.

Brad Hein
+3  A: 

Until Google comes out with support for licensed apps, here's what we did for our MixZing app (note that this assumes a server to enforce the license, but it's not a necessary part of the process if you are willing to lose a substantial amount of revenue to piracy):

  1. Create an "Upgrade" app that people buy just to get an upgrade license. It has no function, and just launches your free app's main activity (optionally with an extra that indicates that it's being launched from the upgrade app).

  2. Have your free app prompt the user for their upgrade license key once it sees that the upgrade app has been installed. The license key is the Google Checkout order number.

  3. Have your server verify the license when the user enters it. You can use the Checkout API to do this.

Some notes and caveats:

  • Due to the Market's 24-hour cancellation policy you have to be prepared to accept the license when they first enter it (assuming of course it's a valid order number at that time) and then reset the user to the free version if they cancel.

  • You need to keep track of licenses and make sure people don't share them.

  • I admit that keeping track of all this on the client and server, getting the state machine right, etc. was more work than we initially imagined.

  • We give the user a three-day grace period to enter their license key, during which time they have use of the premium features.

  • Since we tie the license to the device ID there is a fair bit of support involved in transferring licenses when people replace their phones, flash a ROM that changes the device ID, etc. Of course you don't have to make your license per-device, and having a self-serve option to transfer a license will save a lot of work when we get that done.

All in all, it would be very nice indeed if Google would support licensed apps and save devs and users from all this hassle!

Peter Jeffe
Interesting approach, and MUCH appreciated for all the details. I'll browse the API to see what's available in terms of discovering what packages are installed and whatever other "system reflection" gems are available, as I haven't worked with any of that yet. I'll say that the two games I have "upgraded" did so seemlessly, so I imagine they're doing something like checking for the premium version, firing off an intent for it, and then calling finish on themselves (one actually crashes on resume, so that kind of gives it away that something dynamic/hacky is going on). Thx again.
Rich