Mar*_*KWH 3 android android-gradle-plugin
我的应用程序有多种构建类型和风格gradle。
buildTypes {
release {}
test {}
debug {}
}
productFlavors {
europe {}
asia {}
}
Run Code Online (Sandbox Code Playgroud)
如何根据构建类型和风格的组合命名应用程序?
示例:
Flavor europe会有应用名称AppEurope
BuildType test会在应用名称后面添加“ Test ”后缀,AppEuropeTest
我在表盘中遇到了同样的问题,并尝试将依赖于风格的应用程序名称与依赖于构建类型的应用程序标签值结合起来。我最终这样做了:
在 build.gradle 文件中:
buildTypes {
release {
manifestPlaceholders = [ applicationLabel: "@string/app_name"]
}
debug {
manifestPlaceholders = [ applicationLabel: "@string/app_name_dev" ]
}
}
Run Code Online (Sandbox Code Playgroud)
在 AndroidManifest.xml 中:
<application
[..]
android:label="${applicationLabel}">
Run Code Online (Sandbox Code Playgroud)
在 strings.xml 文件中:
<resources>
<string name="app_name">Classic & Essential</string>
<string name="app_name_dev">Classic & Essential (DEV)</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
我也在我的一篇博文中描述了这一点:https : //www.journal.deviantdev.com/android-build-type-app-name-label/
您的问题已在这里得到解答 -
为所有风格的每种构建类型创建单独版本的 string.xml。
这里有一个示例项目。
https://github.com/commonsguy/cw-omnibus/tree/master/Gradle/HelloBuildType
编辑1
android.sourceSets.europe {
res.srcDirs = ['flavor_resources/europe/res']
}
android.sourceSets.europe.debug {
res.srcDirs = ['flavor_resources/europe/debug/res']
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1637 次 |
| 最近记录: |