Hello, I am an Android developer using windows and eclipse IDE to develop Java Android application. I have published a game, but there is a free version of the game and a paid version. The Google market emphasizes that different versions should have different package names. So far, I am replacing the package with two different names and every time I create different versions I am importing the R resource file. Code 99% is the same for both versions. Is there a better way?
You have various discussions on this topic, but basically the solution project is like a duplicate. For example (not based on eclipse):
It's hard to answer, because we do not know what the difference is between free and non-free versions of your app.
I am convinced that the difference can be controlled by any kind of global free / uninterrupted flag. By this, I mean that the same code will create both versions of the app, and the part that is enabled or used depends on some public static data member somewhere:
< Code> If (SomeClass.IS_PAID_APP) {// add more stuff to the menu etc.}
If you can organize your app in such a way, then you only have one code base is required. Br> Have you set up your app in a way (free or paid, your choice) for your version of that app and to make the appropriate package in your manifest.
Then, add an ant task which does the following:
- Copies your project diary tree at a temporary location
- By searching-and-replace Switch the copy of the manifest to the new package name
- In the new package of the RK version of your old package, search-and-replace again, and then on the copy, your original
< Li> Change your IS_PAID_APP (or whatever) session- Copy the project Execution of the ant build for the field
- Copies copies of binaries to that project by creating a bin / directory
- Deletes a copy of a tree made in step # 1 < / Li>
If there is a pre-printer in Java, the processor, it would be somewhat simpler though, the above mentioned basic technique has been used for a few decades. It's friction, but it works, and this means that you only have a set of source code to deal with, note that ant
& lt; Replace & gt;
The job will handle your search-and-replacement content well