我的应用程序级别 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”。
如何包含基于产品口味的构建变体组合的依赖关系?
最佳答案
为了能够在依赖项中使用多种口味的组合,您需要添加
configurations {
fitGaImplementation {}
}
到您的应用程序。
在the docs中,您可以看到