EDITED
As @doug-stevenson tells us in his answer, the Firebase dependency declaration does not have to be at the bottom of build.gradle anymore.
On the Firebase SDK setup page, it says,
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:9.0.2'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Why is that? Does the ordering matter?
UPDATE: With the latest version of the play services plugin, it is no longer necessary to apply it at the bottom of build.gradle.
It has to do with the way the plugin helps to manage dependencies, and the order of events that Gradle uses to build the project.
The plugin will actually add a dependency on firebase-core if it's not present in your project. It will also check the version of Firebase and Play Services dependencies. However, in order for it to do all this without conflict with other plugins, the Google Services plugin has to run against a project after the project dependencies are already defined. So, applying the plugin after the dependencies block (typically at the bottom of the file) makes all this possible.
The important thing to know is that some projects may experience a version conflict problem if the plugin is at the top. You will avoid these problems by adding it to the bottom.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With