How to get current flavor in gradle(如何在 gradle 中获取当前风味)
问题描述
我的应用有两种产品风格:
I have two product flavors for my app:
现在我想在任务中获取当前风味名称(我在 Android Studio 中选择的名称)以更改路径:
Now I want to get the current flavor name (which one I selected in Android Studio) inside a task to change the path:
如何在 Gradle 中获取 FLAVOR_NAME?
How can I obtain FLAVOR_NAME in Gradle?
谢谢
推荐答案
如何获取当前风味名称
我开发了以下函数,准确返回当前风味名称:
你也需要
在开头或您的脚本中.在 Android Studio 中,这通过使用Make Project"或Debug App"按钮进行编译来工作.
at the beginning or your script. In Android Studio this works by compiling with "Make Project" or "Debug App" button.
如何获取当前风味 applicationId
类似的问题可能是:如何获取 applicationId?同样在这种情况下,没有直接的方法来获取当前的风味 applicationId.然后我使用上面定义的getCurrentFlavor函数开发了一个gradle函数,如下:
How to get current flavor applicationId
A similar question could be: how to get the applicationId? Also in this case, there is no direct way to get the current flavor applicationId. Then I have developed a gradle function using the above defined getCurrentFlavor function as follows:
瞧.
这篇关于如何在 gradle 中获取当前风味的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!