I am trying to find the best method for white labeling an Android application. Basically I want to be able to build multiple versions of almost the same app, each version will have different resources (e.g. drawable icons, colors, etc.) but they will share a lot of the code base. Some of the apps will have additional features as well, so they won't just be clones of each other.
One method I have thought about is separating the shared code into a library, but the issue there is that some of the shared code includes activities so I'm not sure how the resources could be changed in each app.
Another method would be clone and own, but then any bugs or changes in one repository would have to be applied to the other.
Are there any other options? What is the best practice for sharing code, including activities, some resources, and other regular java classes, between two Android apps?
What is the best practice for sharing code, including activities, some resources, and other regular java classes, between two Android apps?
With Android Studio and Gradle for Android, white-labeling can be just a matter of setting up product flavors per customer in that one project. Your common code and default resources go in src/main/
. Your additional code and resource overrides go in src/whateverNameYouGiveYourFlavorForTheCustomer/
. Then, whether from Android Studio (Build Variants view, docked on the left) or from the command line, you can build the different app outputs for each customer-specific flavor.
You are also welcome to go the library route. Resources of the same name defined in an app override the resources from a library.
来源:https://stackoverflow.com/questions/29701600/android-app-white-labeling