1

I have a small Android project that I use as a core project. From this core project I want to be able to do customisations.

So I have the app in a framework format using standard icons, buttons etc... I want to be able to create different versions with different icons and buttons.

This I know how to do. (I will have two separate apk files, both with the same code but with different resources)

However I want to be able to install the core project and a customisation on the same device at the same time. Currently one will overwrite the other.

I have tried to change the package in the manifest but this in turn means I would have to also change all the imports for R.java in my Java files, this is something I want to avoid.

Is it possible to change just something in xml that will allow me to have two projects using the same Java files but with different resources?

inazaruk
  • 74,247
  • 24
  • 188
  • 156
Donal Rafferty
  • 19,707
  • 39
  • 114
  • 191

2 Answers2

2

You should use Android Libraries.

Put all your application code into one Android Library and then create two Android Applications which have custom icons and different package names. The resources defined in final Android Applications will override all already existing resources in Android Library.

One drawback: you'll need to have to almost identical copies of AndroidManifest.xml files in your Android Application (but they still should have different package names).

For more info:

  1. Android's documentation: Settings up Android Library project
  2. My post: Android Application, Android Libraries and Jar Libraries. This one describes how Android Libraries work.
inazaruk
  • 74,247
  • 24
  • 188
  • 156
  • Is this the only option? It seems like a bit overkill for what I want, I already have a split set up in VSS that lets me easily create two projects, my only issue is that they run overwrite each other on install. If a library is my only option it's going to involve splitting the whole thing out again by the looks of it. But I suppose its better than having to change all the R imports – Donal Rafferty Jun 01 '11 at 12:55
  • 1
    You can force 'R class to be located in a package that is independent of package defined in AndroidManifest. But this will require quite some coding (both ant scripts and custom Java tasks for ant). On the other hand, Android Library is not that troubling. Its actually very easy and intuitive when you get used to it. Also, Android Library can be converted into Android Application (and vice versa) in a second. – inazaruk Jun 01 '11 at 13:13
2

You should create a library project that contains all of your source code, and create a project for each of your installable packages that references the library project. You can then define/override any resource definitions in the installable projects

fleetway76
  • 1,600
  • 9
  • 12