我有我的应用级别 build.gradle 文件,其中定义了多种产品口味。我只需要为产品口味的组合添加依赖项。
我的gradle口味是:
flavorDimensions "generic", "custom"
productFlavors {
clover {
dimension "custom"
minSdkVersion 17
}
ga {
dimension "custom"
minSdkVersion 21
}
dit {
dimension "generic"
applicationIdSuffix ".dit"
resValue "string", "app_name", "ADP Time DIT"
}
fit {
dimension "generic"
applicationIdSuffix ".fit"
resValue "string", "app_name", "ADP Time FIT"
}
iat {
dimension "generic"
applicationIdSuffix ".iat"
resValue "string", "app_name", "ADP Time IAT"
}
prodqa {
dimension "generic"
resValue "string", "app_name", "ADP Time QA"
}
prod {
dimension "generic"
resValue "string", "app_name", "ADP Time"
}
}
现在,仅对于gaDit,gaFit,gaIat,gaProd,gaProdqa口味,我才需要“ com.google.firebase:firebase-core:16.0.5”。 我的依存关系部分是:
dependencies {
implementation project(':react-native-background-task')
implementation "com.android.support:appcompat-v7:26.1.0"
implementation 'com.android.support:multidex:1.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
/*changed to accommodate TLSv1 issue. could remove after the issue is fixed in react native*/
// implementation 'com.facebook.react:react-native:+'
implementation project(':react-native-android')
implementation project(':lottie-react-native')
implementation project(':react-native-config')
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
fitGaImplementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
implementation project(':react-native-device-info')
implementation project(':react-native-background-timer')
implementation project(':realm')
implementation project(':react-native-code-push')
// From node_modules
implementation 'com.facebook.fresco:animated-gif:1.10.0'
implementation files('libs/dpuareu.jar')
implementation files('libs/gson-2.8.1.jar')
}
但是,我在构建时遇到了问题,即找不到“ FirebaseInstanceId”。
如何根据产品口味为组合的构建变体添加依赖项?
答案 0 :(得分:0)
要能够在依赖项中使用多种风味,您需要添加
configurations {
fitGaImplementation {}
}
满足您应用的要求。
在the docs中,您可以看到
”,如果您想为结合了 产品风味和构建类型,那么您必须初始化 配置块中的配置名称。 ...”