Can i disable Firebase plugin for specific flavor?

前端 未结 5 759
旧巷少年郎
旧巷少年郎 2021-02-13 03:16

I\'m currently trying out the Firebase analytics suit, but, i have faced one small issue, my app is distributed on both google play and amazon store (which doesn\'t support goog

5条回答
  •  时光取名叫无心
    2021-02-13 03:37

    As per Steve's answer Firebase analytics works even without Google play services. But we still can disable google services plugin for flavors.

    Try add code like this:

     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)
                 }
             }
         }
     }
    

    Here I disable google services for all flavors which their name doesn't contains "flavorName". You should modify the conditions to fit your requirement. And notice that this should be added after apply plugin: 'com.google.gms.google-services'. Hope it helps.

提交回复
热议问题