12

We have several apps that will be very similar in layout and code. The only difference is we will be switching out graphical elements, and making changes to a single constants file and strings file. Of course, theres several problems with this -- the first being namespace. Having an app with the same namespace will overwrite any other apps.

What are some suggestions to doing this? Currently our namesapce is: com.company.appname I figured I could do: com.company.appname.appversion

I've seen post about ant scripts that helps with this, but I'm wondering if theres more fluid solutions now.

bryon
  • 275
  • 1
  • 3
  • 10
  • Not to question the design of your app as I have no idea what its purpose is, but it seems this could be streamlined by having one app with multiple themes? – Will Tate Jan 19 '11 at 20:54
  • If you don't want to use libraries, I've posted a solution here: http://stackoverflow.com/questions/3711967/best-way-to-have-paid-and-free-version-of-an-android-app/13111546#13111546 – Neil Townsend Feb 21 '13 at 16:50

1 Answers1

18

I would suggest looking into Android Library Projects to help with this.

I use this approach for a Lite vs. Free edtions of one of my apps. I have a Library project that contains all of the source and most of the resources for the apps and then 2 projects that use the 1st as a library project, one for Lite and one for Full edition.

The two dependent projects each have their own resources and manifest, allowing the namespace to be different and for me to swap in different strings, drawables, etc. depending on the edition.

I tried the Ant approach but it seemed to be much more of a hassle than the Library project approach. Hope that helps.

Jeshurun
  • 22,940
  • 6
  • 79
  • 92
mmeyer
  • 3,598
  • 1
  • 19
  • 22
  • So, I'm having a hard time figuring out how to do this. I have the main application as a library, but now when I try to overwrite a constants file, it throws errors. I guess this should be expected as thats the way Java works, however I'm not sure how I should do this then. Do I need to import a constants file in the main project that doesn't exist? – bryon Jan 20 '11 at 20:53
  • 1
    Are you saying you've got constants defined in a java class and youre hoping to have that same class in each of your projects with differing values for each edition of your app? Namespace collisions wont allow that. I think you'll need to consider moving your values out into resources, so that they can exist in the main/library project but then be overridden by resources of the same name in the dependent projects. Look at the parts in the Android docs link above that discuss how resources are merged in lib projects. – mmeyer Jan 21 '11 at 00:31
  • I went with this approach and I'm now struggling to make a frictionless upgrade from the free to the paid version, knowing that [two applications cannot offer the same contentprovider](http://stackoverflow.com/questions/3306639/multiple-apps-use-same-content-provider) – rds Dec 09 '12 at 15:02
  • @mmeyer does this mean I have to manage 2 different apps on google play with different app ids and package names? – Ilia Sep 05 '17 at 16:18