for my Android App, I need firebase integrated. So I followed the google tutorial.
now I am always getting after implementing firebase
E/FirebaseApp: Firebase API initialization failure.
when I run the App (on Real Device and Simulation)
Already saw that: Firebase database dependency crashes app
but he is working with old versions...
So my dependencies look like this:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services-location:16.0.0'
//implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.firebase:firebase-core:16.0.5'
}
apply plugin: 'com.google.gms.google-services'
here the projects gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
does anybody know what to do to get rid of this initalization problem?
I think, instead of adding "com.google.android.gms:play-services:", identify what is needed from playservices. Because play services is stuffed with 22 packages and you might not using all of it. This will bloat the apk size and you might cross 65K methods in your project.
I'd advice, you go through this link and pick necessary things you need from playservices.
this is my Project Gradle dependencies
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.0.0'
classpath "io.realm:realm-gradle-plugin:4.2.0"
classpath 'com.google.firebase:firebase-plugins:1.1.1'
this is my App Gradle dependencies
implementation 'com.google.android.gms:play-services-ads:11.4.2'
implementation 'com.google.firebase:firebase-core:11.4.2'
implementation 'com.google.android.gms:play-services-base:11.4.2'
implementation 'com.google.firebase:firebase-messaging:11.4.2'
Also i have change implementation to api ... the error still appears
add below dependency into app level gradle file ..
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
You just need to change your google lib version into the stable version. you are using an unstable version. Use following
implementation 'com.google.android.gms:play-services-location:12.0.0'
implementation 'com.google.android.gms:play-services-places:12.0.0'
implementation 'com.google.firebase:firebase-messaging:12.0.0'
implementation 'com.google.firebase:firebase-core:12.0.0'
and use this classpath
classpath 'com.google.gms:google-services:3.1.1'
and remove the firebase classpath from the project
classpath 'com.google.firebase:firebase-plugins:1.1.1'
Where do you apply the google-services plugin? https://developers.google.com/android/guides/google-services-plugin#introduction requires you apply it at the bottom of your app's build.gradle to avoid dependency collisions similar to the one you are describing.
You can also run ./gradlew :app:dependencies to see if you have any dependency collisions which lead to multiple versions of firebase-core.
I have replaced every occurrence of compile by implementation in my project's build.gradle, but I'm still getting this warning :
I tried to look for "compile " in the whole project but no match was found. So what could be the cause?
I've updated com.google.gms:google-services from 3.1.1 to 3.2.0 and the warning stopped appearing.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath("com.google.gms:google-services:3.2.0")
}
}
I have one same Warning caused to com.google.gms:google-services.
The solution is to upgrade classpath com.google.gms:google-services to classpath 'com.google.gms:google-services:3.2.0' in file in build.gradle Project:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In Android Studio verion 3.1 dependencies complie word is replaced to
implementation
dependencies with Warning in android studio 3.1
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
dependencies OK in android studio 3.1
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Gradel generate by Android Studio 3.1 for new project.
Visit https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html
For details https://docs.gradle.org/current/userguide/declaring_dependencies.html
I've updated com.google.gms:google-services from 3.2.0 to 3.2.1 and the warning stopped appearing.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.2.1'
}
}
Using the currently latest version of the google gms services resolved it for me.
In the project level build.gradle:
buildscript {
...
dependencies {
classpath 'com.google.gms:google-services:3.2.1'
...
}
}
Open up your build.gradle file located here:
This is the old way of writing the dependency libraries (for gradle version 2 and below):
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/volley.jar')
compile 'com.android.support:support-v4:21.+'
}
This is the new (right) way of importing the dependencies for gradle version 3:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation files('libs/volley.jar')
implementation 'com.android.support:support-v4:21.+'
}
Reply by google : https://issuetracker.google.com/issues/74048134
There would be some dependency still using compile, check your application dependencies and transitive dependencies carefully.
https://issuetracker.google.com/issues/72479188 indicates that plugins sometimes can introduce "compile" dependencies and that's what triggers the warning. Probably just easiest to star that issue and wait until they fix it to point out which plugins are causing the issue.
No need to remove the line. As Jkrevis wrote, update the com.google.gms:google-services to 3.2.0 and it stops the warnings.
In my case,it is cause by Realm library,after I update it to latest version(5.1.0 so far) of Realm,the problem solved!
Here is the working gradle script:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "io.realm:realm-gradle-plugin:5.1.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}
I encounter this problem without using com.google.gms:google-services.
The solution solving this kind problem as below:
check build.gradle files of all projects and modules. Or just global search key word 'compile' to find where cause this warning.
if above method cannot solve this warning, then use CLI Command,
./gradlew assembleDebug -d > gradle.log
print detail debug information to a file named gradle.log or any else, as the information is too much. Then search word "WARNING" to find the position in gradle.log, usually you can find what dependence or plugin cause the warning.
Just updating google-service version did not work for me.
First make sure all your dependencies compile are replaced with implementation.
Update all dependencies in your project. Because if one of your dependency is having compile then your project will show this error. So update all dependencies version.
I have tried changing the google gms services to the latest com.google.gms:google-services:3.2.1 in Android Studio 3.0.1 but the warning still persists.
As recommended by the compiler,I changed all compile dependencies to implementation and testCompile to testImplementation like this..
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-ads:12.0.1'
implementation 'com.google.firebase:firebase-crash:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-perf:12.0.1'
implementation 'com.google.firebase:firebase-appindexing:12.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
And finally the warning is removed!
go to your build.gradle file in project level you will find the following lines highlighted
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4' //place your cursor over here
//and hit alt+enter and it will show you the appropriate version to select
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.2' //the same as previously
}
In my case it was an old dependency that was using compile for the transitive dependencies : com.jakewharton.hugo
After removing it from my gradle it compiled.
The workaround to solve this problem was for me that I used an older version of Gradle, which can be found here:
I used the gradle-3.0-rc-1-src version, but others may work too, although probably it should not be newer than the 3.0-version.
First extract the zip file to anywhere you like.
Then go to File -> Settings -> Build, Execution, Deployment -> Gradle and change the setting to Use local gradle distribution. After that make sure that the Gradle Home-field is pointing to the .gradle directory in the directory you just unzipped to.
Rebuild the project and everything should be ok.
The current version is 4.2.0:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
}
Google updated it's services recently in September 2021. Gave update and I faced same issue then I update the build.gradle file in android studio
Old version with issue
classpath 'com.google.gms:google-services:4.3.3'
Updated code in build.gradle
classpath 'com.google.gms:google-services:4.3.10'
You can do this two options:
Add classpath 'com.google.gms:google-services:3.2.0' in ur project: build.gradle dependencies
and
Replace your module: build.gradle in dependency from complile with implementation
and you wont get any warning messages.
Just add from build.gradle from build script
classpath 'com.google.gms:google-services:3.2.0'
and all of the dependencies "compile" replace to "implementation".
that worked from me.
For me changing compile to implementation fixed it
Before
compile 'androidx.recyclerview:recyclerview:1.0.0'
compile 'androidx.cardview:cardview:1.0.0'
//Retrofit Dependencies
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
After
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
//Retrofit Dependencies
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
I treid all the solutions mentioned here, but no luck.
I found in my build.gradle file as below:
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
I just changed it as below and saved and tried build success.
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
Hope that you're affected with build.gradle(app)
If do so , follow this step
Replace compile with androidTestImplementation in build.gradle
androidTestImplementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support:design:27.1.1'
so simple ! hope this will solve
In my case the issue was the Google services gradle plugin with the following line in the gradle file:
apply plugin: 'com.google.gms.google-services'
Removing this resolved the issue
go to you build.gradle (app level)
build.gradle module app
and replace the word "compile" by "implementation"
it will work 100%
I've searched for a lot of solutions to this, but none fit my exact case. I am getting this error on Gradle Sync:
Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.
this is in my build.gradle (app) dependencies.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
and this is in my Project level build.gradle
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Also Important:
It shows a red line under this line:
implementation 'com.google.firebase:firebase-auth:11.8.0'
The message I'm getting if I hover over it:
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.8.0, 11.4.2. Examples include com.google.android.gms:play-services-auth:11.8.0 and com.google.firebase:firebase-analytics:11.4.2
I don't even have an analytics dependency!
What do I do?
Already tried solutions:
If I try to change my com.google.android.gms version, it will throw me a lint saying not to bundle my entire play services in the dependencies. And it also doesn't change the firebase error I'm getting.
Changing firebase to 11.4.2 will throw a lint error.
Changing google play services version to 3.1.1 or below will do nothing.
If I am not wrong, Google services have the dependency on the firebase. I think both are conflicting
check this firebase.google.com/docs/android/setup and adjust google services and firebase dependency versions
Also, make sure you have this at the bottom of your build.gradle (app) file:
apply plugin: 'com.google.gms.google-services'
You might have some third party library in your project using the com.google.firebase:firebase-analytics:11.4.2 version of Analytics. Try to find that.
Try changing it from 11.8.0 to 11.4.2 works for me.
old values
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
new values
implementation 'com.google.firebase:firebase-firestore:11.4.2'
implementation 'com.google.firebase:firebase-auth:11.4.2'
implementation 'com.google.firebase:firebase-messaging:11.4.2'
change this
implementation 'com.google.firebase:firebase-auth:11.8.0'
to
compile'com.google.firebase:firebase-auth:11.8.0'
and make sure that in your applevel build.gradle all google and firebase dependency version should be the same.
it doesnt works try removing google dependency from applevel build.gradle
I am not able to use GoogleSignIn(com.google.android.gms.auth.api.signin.GoogleSignIn
) and GoogleSignInClient(com.google.android.gms.auth.api.signin.GoogleSignInClient
) while implementing Google Sign In in Android Studio while I can access other classes in App like
com.google.android.gms.auth.api.signin.GoogleSignInAccount;
com.google.android.gms.auth.api.signin.GoogleSignInOptions;
com.google.android.gms.common.SignInButton;
A strip down version of my build.gradle(app) file is as follow
android {
}
dependencies {
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-gmail:v1-rev72-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation 'com.google.gms:google-services:3.1.2'
}
apply plugin: 'com.google.gms.google-services'
and my build.gradle(package) is
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.2'
}
}
Any help would be appreciated
add this to your app-level dependency
compile 'com.google.android.gms:play-services-auth:12.0.1'
I was having the same issue
GoogleSignIn and GoogleSignInClient were introduced in version Google Play services SDK version 11.6. In older versions GoogleApiClient was used.
So try changing the compile 'com.google.android.gms:play-services-auth:11.4.2' to 'com.google.android.gms:play-services-auth:12.0.1' in dependencies
dependencies
{
compile 'com.google.android.gms:play-services-auth:12.0.1'
}
For me I was applying a plugin for the google play services in my app's build.gradle:
apply plugin: 'com.google.gms.google-services'
along with that in my Project's Build.gradle I had google services.
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.1.2' // <== this guy
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
I remember I added them with some compiling issues. But apparently I didn't need them.
By removing them I found there were no more issues with the gms versions.
EDIT
So removing solved my issue initially, but gave me issues later with google sign in. adding the apply plugin: 'com.google.gms.google-services' to the bottom of my projects gradle instead of at the top did actually solve it.
In the build.gradle Module script, I had to add these two dependencies, then "Sync Now" and issue resolved for me.
dependencies {
// Your own command lines
//...
compile 'com.google.android.gms:play-services-drive:11.8.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
}
Can't you use any newer version? e.g. 11.6.0.
Try to update your Google Repository as well.
(Tools->Android->SDK Manager->SDK Tools under Support Repository)
Add this line in build.gradle module file under dependencies.
implementation 'com.google.firebase:firebase-auth:21.0.1'
For example:
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation 'com.google.android.gms:play-services-auth:20.2.0'
implementation 'com.google.firebase:firebase-firestore:24.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'de.hdodenhof:circleimageview:3.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}