I am using Fragment for the designing of the Firebase simple login registration.
I get error in the OnCreateView()
method on initializing
As stated in the Google documentation, Add the latest version of the Google Service plugin (4.0.1 on 06/04/18). Hope this hepls!
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
`
I solved the problem in june of 2017 changing the play-services versions for the latest firebase versions (9.6.1). When I used the latest play-services version (10.2.4) I got that error. The code in the gradle looks like this:
Before
compile 'com.google.android.gms:play-services-maps:10.2.4'
compile 'com.google.android.gms:play-services-places:10.2.4'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-auth:9.6.1'
After
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.android.gms:play-services-places:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-auth:9.6.1'
Use:
compile 'com.google.firebase:firebase-auth:11.0.4'
This works.
I solved this exact problem today and stumbled onto this unanswered question by chance during the process.
First, ensure you've properly setup Firebase for Android as documented here: https://firebase.google.com/docs/android/setup. Then, make sure you are compiling the latest version of the Firebase APIs (9.2.0) and the Google Play Services APIs (9.2.0) that you are using. My gradle dependencies look something like this:
dependencies {
...
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
}
Hope this helps!
play services, firebase, gradle plugin latest version combination that worked for me.
try app module build.gradle
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "my package name"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
publishNonDefault true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
dependencies {
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'com.google.android.gms:play-services-analytics:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-iid:17.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
implementation 'com.google.firebase:firebase-crash:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
And project level build.gradle like this
buildscript {
repositories {
maven { url 'https://maven.google.com' }
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.1.0'
}
}
If you use different version of play services libraries, you will get this error.
For example, below entries in build.gradle file cause the error as versions are different.
implementation 'com.google.android.gms:play-services-maps:11.4.2'
implementation 'com.google.android.gms:play-services-location:11.6.0'
To fix the issue use same versions.
implementation 'com.google.android.gms:play-services-maps:11.6.0'
implementation 'com.google.android.gms:play-services-location:11.6.0'