且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android App白色标签

更新时间:2023-12-03 16:43:52


在两个Android应用程序之间共享代码(包括活动,某些资源和其他常规Java类)的***做法是什么?

What is the best practice for sharing code, including activities, some resources, and other regular java classes, between two Android apps?

使用Android Studio和Gradle for Android,白标可以只是设置产品风味每个客户在该项目中。您的公共代码和默认资源位于 src / main / 中。您的其他代码和资源覆盖在 src / whateverNameYouGiveYourFlavorForTheCustomer / 中。然后,无论是从Android Studio(Build Variants视图,停靠在左侧)还是从命令行,您都可以为每个特定于客户的风格构建不同的应用输出。

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.