Dependency in android studio. Plugin Vs Library, DSL Vs API - android

I used Firebase Cloud Message Service in my project. I read Firebase documentation for Integrate in android and see this line to add in build.gradle of project.
classpath 'com.google.gms:google-services:3.0.0'
My question is:
Why we have to use google-service version 3.0.0 ? Instead latest is 9.4.0.
Edition : Tnx Gabriele. As per #Gabriele its a plugin not library. So what is difference between Plugin and Library. What is different between DSL and API? Is API is depends on DSL or DSL is depends on API?

Don't confuse the buildscript dependencies with the library dependencies:
In your buildscript dependencies you are going to define the plugins used by your script. In this case you are adding the google-services plugin
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
In the dependencies section you are going to define the libraries used.
dependencies {
compile 'com.android.support:support-v4:24.1.1'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
}

Related

Faild to resolve: firebase-auth-15.0.0

I am new to android development environment and I need to connect my app to firebase but I am getting this error
Failed to resolve: firebase-auth-15.0.0
This error is shown in the statement:
implementation 'com.google.firebase:firebase-auth:15.0.0' //16.0.1
I tried to change the above statement to
implementation 'com.google.firebase:firebase-auth:16.0.3'
But then firebase dependency is not setting up.
You should use firebase-auth:16.0.4 version.
implementation 'com.google.firebase:firebase-auth:16.0.4'
FYI
At first, add rules to your root-level build.gradle file, to include the google-services plugin and the Google's Maven repository:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.1.0' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
google() // Google's Maven repository
}
}
After that, Clean-Rebuild-Run.
Read Add Firebase to Your Android Project
Update the dependency to the following:
implementation 'com.google.firebase:firebase-auth:16.0.4'
Also add firebase-core:
implementation 'com.google.firebase:firebase-core:16.0.4'
https://firebase.google.com/support/release-notes/android
Please also update google-services plugin in top level gradle file:
classpath 'com.google.gms:google-services:4.1.0'

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 Studio Error The library com.google.android.gms:play-services-measurement-base

How to this i am new on Android Studio.
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
As reported here:
You will need to update the version of the latter dependency to 15.0.2. This addresses the issue where version 3.3.0 of the Google Services Gradle plugin reports: The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2...
Then update your google play services plugin to 3.3.0
classpath 'com.google.gms:google-services:3.3.0'
and update the dependencies to 15.0.2.
Resolve this issue with me - If You are choosing Firestore Database then do this:
first We will add updated these things in Gradle :
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
after this update :
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
implementation 'com.google.firebase:firebase-core:16.0.0'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Then Rebuild or Sunc Now , issue will be resolve.
if You are working on RealTime Database then do this thing :-
Set Dependency :
implementation 'com.google.firebase:firebase-database:15.0.0'
and remove above FireStore Dependency.
This will sure resolve your issue ... If you like then vote for me
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
This works for me. By adding the latest version, i.e 4.0.1

Can't downgrade Android Gradle plugin version

What could be the reason I can't downgrade Android Gradle plugin version?
I have updated to Gradle plugin 2.0 and now I want to use 1.5 but my installed Android Studio says :
> Error:The project is using an incompatible version of the Android
> Gradle plugin. Please update your project to use version 2.1.0
classpath 'com.google.gms:google-services:2.0.0-alpha6'
ad requested in Google Analytics latest version , but the Gradle not working as i want so i want to return to 1.5 .
this is my Gradle file :
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
}
repositories {
mavenCentral()
}
allprojects {
repositories {
jcenter()
}
}
Changing to
classpath 'com.google.gms:google-services:1.5.0'
instead
classpath 'com.google.gms:google-services:2.0.0-alpha6'
and in the inner Gradle file :
compile 'com.google.android.gms:play-services:8.4.0'
instead
compile 'com.google.android.gms:play-services:8.3.0'
Solved the problem .
all i need to check now is the affect on the Google Analyticts but the code compiled and run so at least we know for sure what is the incompatible part .

Gradle DSL method not found: 'comiple()' after putting gcm dependency

I am facing this issue once I put the dependency of GCM.
Error:(50, 0) Gradle DSL method not found: 'comiple()'
Possible causes:The project 'everybill-codebase' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
This is the build.gradle file of line no 50,
comiple 'com.google.android.gms:play-services-gcm:8.4.0'
I am using these services also from play-service
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
this is the build.gradle file in project
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
It would be great to know any solution related with this. Thanks in advance.
Eventually someone is going to close this question, but as the other guys pointed out it's just a typo, use compile() instead of comiple().

Categories

Resources