I understand that the best way to develop a free and paid version of you app is to have a library project which contains the main bulk of the program. The free and paid projects will then use this library project. This allows the free and paid projects to have different resources.
However, my question is how do we limit functionality within the free app (or extend it for the paid app)? For instance, my free app will only be able to access the latest row in a database table whereas the paid app can access all the rows.
One way to do this would be to have a boolean flag in resources somewhere that you set to true for paid and false for free. At runtime the library project checks for the boolean flag and alters behavior accordingly. However, this seems very easily to hack for any potential attacks. Are there better ways?
Would this be easier to complete with one free app and then use in-app billing to unlock the pro functions?
IMHO, Java/Android does not make it easy in this scenario. Ideally you should have one codebase, and able to compile a paid or free version at will. The free version will have critical methods/classes disabled, so that no one can tinker with database or xml to enable full functionality of the app.
One way to do this is with conditional compilation, which again, Java does not support. However, there are some Ant tasks that can do this, e.g. http://prebop.sourceforge.net/doc.html. You can add something in the code like this:
The above code will get removed, if the ant target you are building does not have the variable paid_version defined.
How to setup prebop is another topic altogther, it’s complicated but worth it to have a single codebase.
Update May 2013: The new Android build system based on Gradle makes building paid and free APK slightly easier. See Android Tools website for topic on ‘Build Variants’. In short, you can structure your source like this:
All the shared code reside in
/src/main, paid code in/src/paidand free code in/src/free. The build system will create paid and free APKs for you. However, one feature that is still missing is the ability to do conditional compiling in the source itself. As of this writing, the Gradle build tool is still in beta state, so hopefully this will get added in the final release.