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?
Once your app has been offered for free, the app can't be changed to paid. If you want to charge for the app, you need to create a new app with a new package name and set a price.
If you don't want to release your app on a marketplace such as Google Play, you can make it available for direct download to your users (sideloading). Export the APK file of your application and provide users with the download link.
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):
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).
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.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With