Reputation: 11055
When I setupr gradle file like this every thing is ok:
dependencies {
implementation 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.android.support:support-v4:22.2.1'
}
apply plugin: 'com.google.gms.google-services'
but when I swap the dependencies and plugin, I get this error:
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.android.support:support-v4:22.2.1'
}
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 9.0.0, 11.0.4. Examples include com.google.android.gms:play-services-base:9.0.0 and com.google.android.gms:play-services-basement:11.0.4
Is there any priority in gradle structure and how this relates to the version? Is com.google.gms.google-services
a general syntax for all versions and if not, How should I customize its version here?
Upvotes: 0
Views: 226
Reputation: 300
The apply plugin: 'com.google.gms.google-services'
should always be at the real bottom of your build.gradle
The
google-services
plugin has two main functions:
- Process the
google-services.json
file and produce Android resources that can be used in your application's code. See Adding the JSON File more information.- Add dependencies for basic libraries required for the services you have enabled. This step requires that the
apply plugin: 'com.google.gms.google-services'
line be at the bottom of yourapp/build.gradle
file so that no dependency collisions are introduced. You can see the result of this step by running./gradlew :app:dependencies
.
The Google Services Gradle Plugin
Upvotes: 1