我目前正在尝试 Firebase 分析套件,但是,我遇到了一个小问题,我的应用程序同时分布在 google play 和 amazon 商店(不支持 google play 服务)上,因此对于 amazon 风格,我想要删除对 Firebase 的依赖(我已经知道该怎么做),但是,我还需要删除 Firebase 插件,以便在构建时不会引发异常。
这是我目前所拥有的:
productFlavors {
google {
applicationId 'google app id'
}
amazon {
applicationId 'amazon app id'
}
}
dependencies {
googleCompile 'com.google.firebase:firebase-analytics:9.0.0'
amazonCompile 'com.amazonaws:aws-android-sdk-mobileanalytics:2.2.12'
amazonCompile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'
但是,只有在亚马逊风格的情况下我才需要删除该插件。
这可能吗?或者至少有什么我可以尝试的接近的东西吗?
UPDATE:
根据 Steve 的要求,我在我的 Amazon Kindle 平板电脑上尝试了带有 Firebase 的版本,即使没有安装 Google Play 服务,它也能正常工作。
根据 Steve 的回答,即使没有 Google,Firebase 分析也能正常工作
游玩服务。但我们仍然可以禁用谷歌服务插件
口味。
尝试添加这样的代码:
apply plugin: 'com.google.gms.google-services'
android.applicationVariants.all { variant ->
if (!variant.name.contains("flavorName")) {
project.tasks.each { t ->
if (t.name.contains("GoogleServices")) {
// Remove google services plugin
variant.getVariantData().resourceGenTask.getTaskDependencies().values.remove(t);
// For latest gradle plugin use this instead
// variant.getVariantData().taskContainer.sourceGenTask.getTaskDependencies().getDependencies().remove(t)
}
}
}
}
在这里,我禁用了所有名称的谷歌服务
不包含“flavorName”。您应该修改条件以适应
您的要求。请注意,这应该添加在之后
apply plugin: 'com.google.gms.google-services'
。希望能帮助到你。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)