Hello I am a beginning android developer using windows and the eclipse IDE to develop java android applications.I have published one game but there is a free version of the game and a paid version. The google market insists that the different versions must have different package names. So far i have been refactoring the package with 2 different names and changing the R resource file import each time i build the different versions. The code is 99% the same for both versions.Is there a better way?
Definition of android : a mobile robot usually with a human form sci-fi androids.
Whether iOS is better than Android in security is now up for debate, but the consensus still gives Apple the upper hand. iOS has more consistent updates for all devices, a closed ecosystem that is harder to penetrate, and a stricter app store.
You Want More Freedom, Control, and Customizations. Since Android is an open-source platform, it offers more freedom and customization options than iOS. You can customize almost anything on your Android device, from how your home screen looks to how you interact with your phone.
Samsung is just one manufacturer that uses Android. Others include Sony, Motorola, LG, OnePlus, and Huawei. But while all of these manufacturers use Android on their phones, that doesn't mean the experience is the same on all of them. This goes back to the open-source nature of Android.
You have various discussions on this topic here and there, but basically the solution is akin to duplicate the project.
For instance (not based on eclipse):
It is difficult to answer this, since we don't know what the difference is between the free and not-free versions of your app.
I'm going to assume that the differences could be handled by some sort of global free/not-free flag. By that, I mean that the same code would make up both versions of the app, and which portions are enabled or used would be dependent on some public static data member somewhere:
if (SomeClass.IS_PAID_APP) {
// add more stuff to menu, etc.
}
If you can organize your app that way, then you only need one code base.
Have it set to build your app one way (free or paid, your choice) and with the proper package in your manifest for that version of the app.
Then, add an Ant task that does the following:
- Makes a tree copy of your project dir to a temporary location
- Switch the copy of the manifest to the new package name via a search-and-replace
- Switch all import statements for your old package's edition of R to the new package, again via search-and-replace, and again on the copy, not your original
- Change your IS_PAID_APP (or whatever) to the opposite value (search-and-replace in the copy)
- Executes an Ant build for the copy of the project
- Copies the binaries from that build to the main project's bin/ directory under a distinct name (so it doesn't clobber your other copy of the APK)
- Deletes the tree copy made in step #1
If Java had a pre-processor, this would be somewhat simpler. However, the basic technique that I describe above has been used for a couple of decades now. It's clunky, but it works, and it means you only have one set of source code to deal with. Note that the Ant
<replace>
task would handle your search-and-replace stuff nicely.
This is one of the failings of Android Market though I can see why they did it that way. It just wasn't designed for having Free and Paid versions of your app (they claim the 24hr return policy is what this is for, but that's instead used for piracy)-:
Anyways, simplest thing to do is to write an Ant build script (or whatever scripting language you use). Do a search replace of your package name through all the .xml and .java files. Then do the build of your app there. Refactoring your code is more pain than it's worth IMHO...
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