Android – deploy multiple versions of the same app

So you have paid and free version of the same app and you want to deploy both to the Android Market (AM). There you’ll have a nasty surprise – AM wants to identify your app by its package and you will have to move one of the versions to the another package. I had to do it for my DroidIn app so here’s least painful way of doing it that I could come up with:

Let say you have your paid version in com.foo.widget and you want your free app to be in com.foo.widget.free

  1. Deploy your paid version to the AM
  2. Come back to your code and open Android manifest
  3. Change <manifest package=”com.foo.widget”/> to <manifest package=”com.foo.widget.free”/>
  4. Save it – and you will be horrified with all errors in your project at this point
  5. The most important thing from this point on – you will no longer be able to refer to your activities and services by a shortcut in the manifest file. The example of shortcut? Here – <activity android:name=”.HOME”/>
  6. You will have to refer to these by full package name so the element above will look like <activity android:name=”com.foo.widget.free.HOME”/>
  7. Save the manifest again. Now your R generated file will appear in the new package (ROOT/gen/com.foo.widget.free.R.java)
  8. Which means you will have to go to your activity(s) source file, or any file that refers to R.class and change import statement(s) to look at the new location. The more files you have, the more painful that will be, of course.
  9. When you no longer have compilation errors change @string/app_name to reflect free version and you ready to package and deploy

If you know of easier way of achiving the same result – please let me know, I would love to hear it

This entry was posted in android, DroidIn. Bookmark the permalink.

5 Responses to Android – deploy multiple versions of the same app

  1. Madhurima says:

    This is wonderful. Thanks.

  2. AndrDev says:

    Maybe I am missing something, but if I have to change my source code for a specific package, then how do I support com.mycom.android.free and com.mycom.android.paid without having to keep a duplicate of my whole codebase?

  3. Pingback: 無料版と有料版の切り替えに苦戦中 | DailyTimer.net Blog

  4. Torben Putkonen says:

    Having read several solutions I have come to the conclusion that CVS or SVN are the right way.

    1. Put code to CVS or SVN.
    2. Add a static and final constant that controls whether app is paid or free.
    3. Develop the paid version.
    4. Commit code to CVS/SVN.
    5. Create a branch for the free version.
    6. Edit branch to include necessary changes for free version (package, references to R.java, the constants, etc.)

    When developing new features, implement them to the paid version first and when they are ready, merge them to the free branch. If possible, it helps to design the codebase so that any possible version-specific code is clearly separated to specific files, not all over the codebase.

    Any solution that involves Ant or Maven scripting that manipulate the code before building (or god forbid, straight up "bytecode raping" :)) are an extremely bad idea. I have learned in my day job that whatever code you deliver must exist "as is" in version control. If you ship manipulated code, you don't know what code was executed when a user reports an error.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>