一个应用程序的多个品牌 [英] One app multiple branding
问题描述
我有两个应用程序共享,除了图像,图标,颜色,应用程序的名称和包装的变化和被调用网络活动时的URL相同的功能。
I have two apps that shares same functionality except images,icons,colors,app name and package change and the URL that gets called in the event of network activity.
在iOS的,我们可以通过使用的目标的力量创造一个来源$ C $ C两个不同的应用程序中轻松的。
In iOS we can create two different apps easily from one source code by using the power of targets.
下面是如何做到这一点IOS中的链接
Here is the link on How to do it in iOS
但如何去它的android
But how to go about it in android
推荐答案
您应该充分利用的产品口味了解这一点。
You should leverage product flavors for this.
在你build.gradle,您将定义像这样的味道:
In your build.gradle, you will define the flavors like so:
android {
productFlavors {
brand1 {
// ...
}
brand2 {
// ...
}
}
}
然后,您可以创建风味的特定资源。如果您正在创建称为图标 ic_launcher.png
例如,您通常把它放在一个位置,如主/ RES /绘制-xhdpi / ic_launcher.png
。相反,你可以把brand1版本 brand1 / RES /绘制-xhdpi / ic_launcher.png
和brand2版本 brand2 / RES / drawable- xhdpi / ic_launcher.png
。
You can then create flavor specific resources. If you are creating an icon called ic_launcher.png
for example, you would typically put it at a location such as main/res/drawable-xhdpi/ic_launcher.png
. Instead, you could put the brand1 version at brand1/res/drawable-xhdpi/ic_launcher.png
and the brand2 version at brand2/res/drawable-xhdpi/ic_launcher.png
.
当您运行 gradlew构建
,将构建所有的变种。您也可以通过指定变量名称,像这样建这样的特定变体: gradlew assembleBrand1Debug
。在Android的工作室,你希望看到用建变种窗格中,您可以选择的变体。
When you run gradlew build
, it will build all variants. You can also build specific variants such by specifying the variant name like so: gradlew assembleBrand1Debug
. In Android Studio you can select the variant you want to see using the "build variants" pane.
这篇关于一个应用程序的多个品牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!