我的build.gradle中有下一段代码:
productFlavors {
//DIMENSION - APP
slid {
dimension "app"
applicationId "com.slid"
versionCode 1
versionName "1.0.0"
manifestPlaceholders = [one_app_id : "273e0-b8f-4c7f-87-0f4eb68da"]
}
}
我想要做的是从我的java代码中的one_app_id
访问manifestPlaceholders
。
由于我无法这样做(或者至少我无法找到方法),我想要定义一个buildConfigField
String
,其值273e0-b8f-4c7f-87-0f4eb68da
但是我'我想把它作为manifestPlaceholders/one_app_id
的引用,所以我不会两次写ID。
我的问题是:
buildConfigField "String", "ONE__ID", '[reference_here]'
我应该设置什么而不是[reference_here]
?
或
我该如何操作,即将ID设置为buildConfigField
,然后在manifestPlaceholder
中设置该引用
例如manifestPlaceholders = [one_app_id: [?!reference_here?!]]
P.S。不用担心,ID无效:)
答案 0 :(得分:0)
根据CommonsWare的建议,我设法做到了这样:
ext {
oneAppId = ""
}
android {
productFlavors {
//DIMENSION - APP
slid {
dimension "app"
applicationId "com.slid"
versionCode 1
versionName "1.0.0"
ext.oneAppId = '"273e0-8567-558da"'
manifestPlaceholders = [one_app_id : ext.oneAppId] //Used by the third party library
buildConfigField "String", "ONE_APPID", ext.oneAppId //I'll use this in java
}
}
}