Jor*_*lar 12 android firebase android-gradle-plugin gradle-plugin firebase-analytics
我目前正在试用Firebase分析套装,但是,我遇到了一个小问题,我的应用程序分发在谷歌播放和亚马逊商店(不支持谷歌播放服务),所以对于我想要的亚马逊风味删除对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'
Run Code Online (Sandbox Code Playgroud)
但是,我需要删除插件只有亚马逊风味.
这甚至可能吗?或者至少有一些我能尝试的东西吗?
更新:
根据史蒂夫的要求,我去亚马逊Kindle平板电脑上尝试使用Firebase的版本,即使你没有安装Google Play服务也能正常工作.
Jun*_*Cao 11
根据Steve的回答,即使没有Google Play服务,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)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我禁用谷歌服务的所有口味,他们的名字不包含"flavorName".您应该修改条件以满足您的要求.请注意,这应该在之后添加
apply plugin: 'com.google.gms.google-services'.希望能帮助到你.
我终于有了一个可以与新gradle一起使用的版本。经过gradle 4.6测试,构建工具3.0.1,google-services插件3.1.1
应用插件:“ com.google.gms.google-services”
android.applicationVariants.all {变体->
如果(variant.name =='someVariantNameYouDontwantFirebase'){
project.tasks.getByName('process'+ variant.name.capitalize()+'GoogleServices')。enabled = false
}
}
尽管 Firebase 并不正式支持没有 Google Play 服务的设备,但 Analytics 实际上应该可以在此类设备上运行,因此您实际上可能不需要在 Amazon 构建中禁用 Firebase(或删除插件)。你试过了吗?
| 归档时间: |
|
| 查看次数: |
2826 次 |
| 最近记录: |