Can't add the library firebase to classpath - android

I have followed the Firebase tutorial and I have also checked several times if I have made any mistakes but I can't find it.
The problem is that when I try to add the library to classpath nothing happens. You see in this picture I get the pop-up screen but it remains red after my click and not imports?

You Must Add these dependencies into your build.gradle (Module) file:
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
Also add google-services classpath to build.gradle (Top-level):
classpath 'com.google.gms:google-services:4.1.0'
And It is important to successfully run the application add google-services.json in
app module folder with enable plugin at build.gradle (Module) file:
apply plugin: 'com.google.gms.google-services'

Related

Gradle sync fails - play-services-measurement-base

I have a problem on my Android project, I can't build, this is the error I have:
Failed to notify dependency resolution listener.
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.2,15.0.2], [15.0.4,15.0.4]], but resolves to 15.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
I tried many different solution I found but the problem persists.
I have the right dependencies and repositories on gradle file on project root:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
}
and
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven {
url "https://maven.google.com"
}
}
On my app gradle I have the following dependencies:
implementation "com.google.android.gms:play-services-maps:15.0.1"
implementation "com.google.android.gms:play-services-places:15.0.1"
implementation "com.google.android.gms:play-services-gcm:15.0.1"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-analytics:15.0.2"
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation "com.google.android.gms:play-services-tagmanager:15.0.2"
implementation "com.google.firebase:firebase-core:16.0.0"
Some suggestions?
The solution was update the following dependencies:
implementation "com.google.android.gms:play-services-analytics:16.0.0"
implementation "com.google.android.gms:play-services-tagmanager:16.0.0"
I just added right after the apply plugin: 'com.google.gms.google-services' at the bottom of my build.gradle :
apply plugin: 'com.google.gms.google-services'
// Work around
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
I had the same exact error, upgrading analytics was the key:
implementation 'com.google.android.gms:play-services-analytics:16.0.0'
I know you thought everything is updated referring to the official website, but writing 15.0.0 and looking for suggestions works better.
Update project gradle play service dependency with latest release :
classpath 'com.google.gms:google-services:4.0.1' and
Update project firebase products usage as per firebase latest release note
this shoud be on top if you use firebase libraries:
implementation "com.google.firebase:firebase-core:16.0.0"
This worked for me.this shoud be on top if you use firebase libraries:
implementation "com.google.firebase:firebase-core:15.0.0"
In my case the issue was OneSignal, which somehow broke everything down.
They even have a dedicated library for this: https://github.com/OneSignal/OneSignal-Gradle-Plugin
and the actual issue was that OneSignal was inside my app-level gradle, instead of root one.
Freaking ridiculous!
Check Answer by Bhupendra Acharya from
https://groups.google.com/forum/#!topic/firebase-talk/XbGR-YrsTTA works for you. I got the following error
The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 16.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
While using
implementation 'com.google.firebase:firebase-core:16.0.1'
And resolved by updating the version
implementation 'com.google.firebase:firebase-core:16.0.4'
My problem was that I was importing oneSignal gradle plugin but I do not import the full apply plugin: 'com.google.gms.google-services'.
To fix I just had to add the implementations I was using.
For future users: Open build.gradle files and just hover your mouse on the dependencies and a tooltip gonna show up telling your the newest version and that should solve your problem.
Beware that Firebase Documentations does not have the newest versions.
update classpath for com.google.firebase:firebase-core:16+
classpath 'com.google.gms:google-services:4.2.0'
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
}
Try this one , place maven url on top inside repositories in build.gradle
Update build.gradle
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2' //< update version
classpath 'com.google.gms:google-services:3.1.1' //< update version
}
}
This would help you I guess
Update the build.gradle file from the project root folder. I've tried this and it was helping.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
----
}}
Make sure you added following line in bottom of app gradle
apply plugin: 'com.google.gms.google-services'
Make sure you are using compatible google-services in project level gradle
dependencies {
classpath 'com.google.gms:google-services:4.0.1'
}
Check if you have added following dependency
implementation 'com.google.firebase:firebase-core:16.0.1'
I have answered a similar issue here. You need to keep versions of play services and firebase to latest one. Check here for links
https://stackoverflow.com/a/52696667/3333878
Try to set
classpath 'com.google.gms:google-services:3.2.1'
instead of
classpath 'com.google.gms:google-services:4.0.1'
It's helped in my case, but I don't know the cause of the error.

Android app with firebase implementation

How to fix "Could not find com.google.gms:google-services3.0.o " Even after adding json file andgoogle-services.json file applying plugin for it
This is where i applied plugin for google services
[Classpath dependencies][3]
add this in your project module gradle
classpath 'com.google.gms:google-services:3.0.0'
add dependencies
compile 'com.google.android.gms:play-services-auth:10.2.0'
}
apply plugin: 'com.google.gms.google-services'

Firebase in android showing error while adding dependency to android studio 2.1.2

classpath 'com.google.gms:google-services:3.0.0'
I have added this too in app dependency, but its showing error.
compile 'com.google.firebase:firebase-ads:9.0.2'
add this in dependencies under app gradle
and this under build.gradle
classpath 'com.google.gms:google-services:3.0.0'
I recomand you using in your dependencies the last version of Firebase. At the moment the last versions is 11.0.4.
compile 'com.google.firebase:firebase-core:11.0.4'
You need to do this change for all your dependencies existing in your build.gradle file.

Unable to resolve google-service dependency

I am setting up the first project of android with firebase following this Add Firebase to Android docs and stuck at resolving google play service dependency it says
I also google it but couldn't find any helpful answer.
In Project:Gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
In App:Gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-core:9.0.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Is anything i am missing? what should i do as i read my answers here at stackoverflow but none of them were useful
You have set up the plugin and dependencies correctly, but you need the google-services.json configuration file from the Firebase Console.
If you've not connected an app, select "Add Firebase to your Android app", enter the package name, and hit Add App. This should download the file.
If you connected before, click on the cog in the left nav, select Project Settings, and download the google-services.json associated with your project.
You need to download this and put in your app directory (next to the app build.gradle).
for me solved by add this In Project:Gradle
in :
buildscript {
///////////////////*blah blah*/
classpath 'com.google.gms:google-services:3.0.0'
repositories {
jcenter()
}
}

Found com.google.android.gms:play-services:8.4.0, but version 8.3.0 is needed for the google-services plugin

Can't use google maps because of above said error. Anyone find the same issue ?
Make sure that the following line is at the end of the app build.gradle file:
apply plugin: 'com.google.gms.google-services'
Mine was on the top and gradle was defaulting to 8.3.0 instead of what was specified: 8.4.0
My build.gradle files are the same as the ones in the Version conflict updating to 8.4.0
As those previous anweres are only part-wise complete.
Here are my three steps which worked fine for me:
Put this to the end of your apps build.gradle
apply plugin: 'com.google.gms.google-services'
Set your projects build.gradle dependencies to
'classpath 'com.google.gms:google-services:2.0.0-alpha5'
Set Gradle Version to 2.10
Android Studio: File > Project Structure > Project
#redsonic's answer worked for me.. By simply moving apply plugin:
'com.google.gms.google-services' after the dependecies in
build.gradle (Module: app)
I'm using Android Studio 1.5.1 with Gradle version 2.10
In case you are using Gradle version older than 2.10 you'll also need to update that by selecting the ProjectName or app directory in the Project tool Windows and pressing F4. This will open Project Structure window, select Project from the menu and update Gradle version to 2.10. Press OK (Android Studio will download it in background).
build.gradle (Project: ProjectName)
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
build.gradle (Module: app)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
This is a slight variant of #Lord Flash's answer:
For me it wasn't necessarily that I should place the google services plugin at the bottom of the file it was that it should come before the com.android.application plugin.
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
Also there are newer binaries than the alpha variants for google-services
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:2.0.0-beta6'
}
}
I'm sure there will be newer ones soon. I found the list of variants here
follow all the steps at this link Add App Invites to Your App
use this : compile 'com.google.android.gms:play-services-appinvite:8.4.0'
instead of this : compile 'com.google.android.gms:play-services:8.4.0'
please follow all the steps and then build the project
hope thats help
I had the same problem, and I found that moving:
apply plugin: 'com.google.gms.google-services'
To the bottom of the module app gradle.
and then use:
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:2.1.0'
The problem is that some of your app dependencies that start with com.google.android.gms: have a version that is incompatible your project dependencie classpath 'com.google.gms:google-services:
Check for these on your app build.gradle
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
And for this in your project build.gradle
classpath 'com.google.gms:google-services:1.5.0'
You can update your project build.gradle to use the latest google-services version or your can just change your app dependencies to use the 8.3 version.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// this should solve the gradle update error if it persists even after following above steps
Make sure that the following line is at the end of the app build.gradle file:
compile 'com.google.android.gms:play-services:11.0.2'
google update there API day by day.Now mine is '11.0.2'
try with the updated API

Categories

Resources