Android App白色标签 [英] Android App White Labeling

查看:390
本文介绍了Android App白色标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到为Android应用程序添加白色标签的最佳方法。基本上我希望能够构建几乎相同的应用程序的多个版本,每个版本将具有不同的资源(例如可绘制的图标,颜色等),但是它们将共享许多代码库。一些应用程序也会有其他功能,所以它们不会只是彼此的克隆。

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.

还有其他选项吗?在两个Android应用程序之间共享代码(包括活动,某些资源和其他常规Java类)的最佳实践是什么?

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?

推荐答案


在两个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.

这篇关于Android App白色标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆