本文介紹了在 gradle 中設(shè)置一個(gè)可以在清單文件中使用的全局變量的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我想創(chuàng)建一個(gè)類(lèi)似于 applicationId 的全局變量.它是 build.gradle 中的設(shè)置值,將在 manifest 中使用.是否可以?
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?
推薦答案
你可以設(shè)置,比如我是針對(duì)不同的產(chǎn)品風(fēng)格設(shè)置的
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" />
這篇關(guān)于在 gradle 中設(shè)置一個(gè)可以在清單文件中使用的全局變量的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!