1
votes

i want to start using gcm in my project, and i follow google instruction for that, but when i add dependencies in my build.gradle file as follow :

top level : classpath 'com.google.gms:google-services:3.0.0'

project level : apply plugin: 'com.google.gms.google-services'

i have an error that says you must add firebase to your dependencies :

freeCompile 'com.google.firebase:firebase-core:9.0.0'

but after i add this to my dependencies i have another error like this :

Error:(74, 0) Gradle DSL method not found: 'freeCompile()' Possible causes:

  • The project 'testGCM' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • 1
    freeCompile specifies the gradle dependency block that only compile firebase for the product flavor free , so you if have not defined a free product flavor then ofcourse its not going to work, in this case you can either add a new product flavor called free or just replace freeCompile with compile , this will compile the firebase-core lib and make it available for all product flavors - Bhargav

    1 Answers

    2
    votes

    freeCompile specifies the gradle dependency block that only compile firebase-core for the product flavor free , so you if have not defined a free product flavor then ofcourse its not going to work.

    In this case you can either add a new product flavor called free like so

    android {
        ...
    
        productFlavors {
            free {
                versionCode 1
                versionName "1.0.0"
            }
       }
    
       ...
    }
    

    OR just replace freeCompile with compile , this will compile the firebase-core lib and make it available for all product flavors