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