小编Arc*_*ana的帖子

如何替换 build.gradle 的 ProductFlavours 中的 string.xml 值

在 strings.xml 中

<resources>
<string>name="app_name">App_Name</string>
<string>name="app_port">https://example.com</string>
<string>name="app_key">App_Key</string>
</resources>
Run Code Online (Sandbox Code Playgroud)

在 build.gradle 中

productFlavors {
    production {
        applicationId = "com.example.production"
    }
    staging {
        applicationId = "com.example.staging"
        //code to manipulate strings.xml value because for production and staging app_name, app_port and key are different
    }
}
Run Code Online (Sandbox Code Playgroud)

我需要一个代码来操作 build.gradle 文件的 ProductFlavours 中的 strings.xml,而不是为暂存和生产创建单独的文件夹。

xml android

1
推荐指数
1
解决办法
2611
查看次数

标签 统计

android ×1

xml ×1