Search code examples
androidxmlcustomising

Same project but customised and installable alongside each other?


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?


Solution

  • 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.