在清单中使用变量 [英] Use variables in manifest
本文介绍了在清单中使用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Android中集成某些库(例如Branch-io
)需要在项目清单中定义元数据.其中一些变量类似于TestMode
Integrating some libraries like Branch-io
in Android need to define meta-data in project manifest. some of this variable is like TestMode
<meta-data android:name="io.branch.sdk.TestMode" android:value="true" />
因此,当我们要发布应用程序时,应将其更改为False.
So, when we want to publish the application we should change it to False.
有什么方法可以根据BuildType
在某处定义变量并将其分配给该变量的元数据吗?
Is there any way to define a variable somewhere according to BuildType
and assign it to the Meta-data to that?
推荐答案
您可以通过添加清单占位符到您的 build.gradle 文件:
You can do it by adding manifestPlaceholders to your build.gradle file:
android {
...
buildTypes {
debug {
manifestPlaceholders = [isBranchSdkInTestMode:"true"]
...
}
release {
manifestPlaceholders = [isBranchSdkInTestMode:"false"]
...
}
}
...
}
在 AndroidManifest.xml 中,您可以将其用作${isBranchSdkInTestMode}
:
In AndroidManifest.xml, you can use it as ${isBranchSdkInTestMode}
:
<meta-data android:name="io.branch.sdk.TestMode" android:value="${isBranchSdkInTestMode}" />
这篇关于在清单中使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文