在gradle中设置一个可以在清单文件中使用的全局变量 [英] Set a global variable in gradle that can use in manifest file

查看:204
本文介绍了在gradle中设置一个可以在清单文件中使用的全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个与applicationId类似的全局变量. 它是在build.gradle中设置的值,并将在清单中使用.是否有可能?

I want to create a global variable similar with applicationId. It is set value in build.gradle and will be used in manifest. Is it possible?

推荐答案

您可以设置它们,例如,我为不同的产品口味设置了

You can set them, for instance I'm setting it for different product flavors

productFlavors {
        production {
            applicationId = "com.myapp.app"
            resValue "string", "authority", "com.facebook.app.FacebookContentProvider5435651423234"
        }
        development {
            applicationId = "com.myapp.development"
            resValue "string", "authority", "com.facebook.app.FacebookContentProvider2134564533421"
        }
        qa {
            applicationId = "com.myapp.qa"
            resValue "string", "authority", "com.facebook.app.FacebookContentProvider29831237981287319"
        }
}

并像这样使用它

<provider
    android:name="com.facebook.FacebookContentProvider"
    android:authorities="@string/authority"
    android:exported="true" />

这篇关于在gradle中设置一个可以在清单文件中使用的全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆