Unable to update the Firebase dependency(com.google.firebase) - android

I have Added Firebase to android app for push notification. I have updated build.gradle before i have used. Its working fine.
compile 'com.google.firebase:firebase-messaging:9.2.0'
now i have updated to latest library but getting error.
dependencies {
//....
compile 'com.google.firebase:firebase-core:10.0.1'
}
I had getting error at the time of Rebuild project
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not find com.google.firebase:firebase-core:10.0.1.
Required by:
DGApp:app:unspecified
Thank you in advance.

You have to update your Google Play Services and Google Repository from the Standalone SDK Manager.
Edit: As of the latest version of Android Studio the Standalone SDK Manager is removed. You must go to the SDK Tools tab.
First off, open Android Studio and click this icon at the top toolbar:
Then, when the dialog launches, click "Launch Standalone SDK Manager" at the bottom left of the dialog:
To make sure nothing other than what we want gets updated/installed, click "Deselect All":
When the Standalone SDK Manager window opens, look for "Extras" and collapse it. You should see "Google Play Services" and "Google Repository" and on the right you should see "Update Available: {something}". Select these to items and click "Install".
When they're done installing, the error will go away.

Add the google-services plugin
In build.gradle file, to include the google-services plugin:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
Then, in your module Gradle file (usually the app/build.gradle), add the apply plugin line at the bottom of the file to enable the Gradle plugin:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.0.1'
// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
More details refer Firebase setup

If you read documentation they are indicating you update your latest Google Repository in the Android SDK manager
So just go to Android SDK Manager and install the latest version of below two libraries
1-Google Play Services
2-Google Repository
Check the image from documentation:

Getting a "Could not find" error? Make sure you have the latest Google Repository in the Android SDK manager.
To reseolved the problem;
Open SDK Manager and update the SDK Tools for latest especially Google APIs under Android 7.0(API 24)

May be you are not giving the right repo.
repositories {
maven { url 'https://maven.fabric.io/public' }
}
}

Related

Error when migrating Crashlytics to Firebase Android

I'm basically following the migration guide from within Crashlytics (which is pretty much summarized in this post).
I followed the same instructions verbatim, you can see that from my git diff:
Yet when I sync my Gradle, I get this error:
5:02 PM Gradle sync failed: Could not find method compile() for
arguments [com.google.firebase:firebase-core:11.4.2] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Update
As mentioned in the comments (and as experienced by us at the end), we shouldn't migrate anyway until further notice:
Update 2
In fabric, if you click on Crashlytics, there is a link on the left nav bar that says Firebase, when you click on it you get this ad
The buildscript block is not a place for your application level dependencies. See this answer for more information on the buildscript block.
You need to place your compile or implementation/api(for gradle 3.4+ and android gradle plugin 3.0+) dependencies into the separate dependencies{} block with the rest of your dependencies, that is usually on the same level as your android plugin configuration.
In your project level grade file, you need to add, maven {
url 'https://maven.fabric.io/public'
} to the repositories.
add the following to your dependencies classpath 'io.fabric.tools:gradle:1.25.1''
In your app level Gradle file put apply plugin: 'io.fabric' below apply plugin: 'com.android.application' and under depencies place this implementation('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
place apply plugin:'com.google.gms.google-services' at the bottom of the app level gradle file.
Change compile '...' to implementation '...'
You are using Google Services plugin 3.0.0. The instructions for adding the Crashlytics SDK indicate that 3.1.2 or higher is required:
Note: Crashlytics requires Google Services plugin version 3.1.2 or
higher. Check the com.google.gms:google-services version number in
your project's build.gradle dependencies.

Firebase assistant not showing in Studio 2.2.3

I am trying to connect Firebase with my app and I was following all the steps in this link.
I have the latest Google Repo and android studio 2.2.3, but when I open the Tools drop down menu there is no Firebase option.
Any idea of what I am missing?
In the Android Studio, go to File -> Settings, click on Plugins and then enable all Firebase plugins.
This image below should help.
First you need to sign in to your Google account by clicking on the icon in the upper right corner of android studio. Then the Firebase item will appear in the Tools menu.
In android studio 3.6.1 I used the long way but it worked as shown below:
Log in to Android Studio 3.6.1 from the to right user icon
Log in to firebase console with the same account address
On the firebase console start a new project
In the center of the project overview page, click the Android icon (plat_android) to launch the setup workflow.
5.Enter your app's package name in the Android package name field
Add the Firebase Android configuration file to your app by:
Click Download google-services.json to obtain your Firebase Android config file (google-services.json).
Move your config file into the module (app-level) directory of your app.
To enable Firebase products in your app, add the google-services plugin to your Gradle files.
In your root-level (project-level) Gradle file (build.gradle), add rules to include the Google Services Gradle plugin. Check that you have Google's Maven repository, as well.
11
`buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// ...
// Add the following line:
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}`
11
.In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin:
apply plugin: 'com.android.application'
// Add the following line:
apply plugin: 'com.google.gms.google-services' // Google Services plugin
android {
// ...
}
Add Firebase SDKs to your app
To your module (app-level) Gradle file (usually app/build.gradle), add the dependencies for the Firebase products that you want to use in your app.
dependencies {
// ...
// Add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.3.0'
// Add the dependencies for any other Firebase products you want to use in your app
// For example, to also use Firebase Authentication
implementation 'com.google.firebase:firebase-auth:19.3.0'
// Getting a "Could not find" error? Make sure that you've added
// Google's Maven repository to your root-level build.gradle file
}
Sync your app to ensure that all dependencies have the necessary versions.
If you added Analytics, run your app to send verification to Firebase that you've successfully integrated Firebase. Otherwise, you can skip the verification step.
Your device logs will display the Firebase verification that initialization is complete. If you ran your app on an emulator that has network access, the Firebase console notifies you that your app connection is complete.
In Android Studio 3 , Go To Tools - > Android - > SDK Manager - > under that plugins in which search Firebase and there are three plugins click all then your android studio restart and can see Firebase Assistant there under tools ... Enjoy
Android Studio 3.4.1, Go to Tools -> Firebase

Could not find: com.google.firebase:firebase-core:9.6.1

I get the following error while integrating Firebase into my project for the first time.
Could not find: com.google.firebase:firebase-core:9.6.1
I followed the steps mentioned on the Firebase documentation, in the section Add Firebase to your Android Project, topic Available libraries.
I updated my packages Google Play Services (rev 33) and Google Repository (rev 32).
What are my options to resolve this error?
Upgrade you Google Repository to rev 36. com.google.firebase:firebase-messaging:9.6.1 is available from rev 35.
The latest version of Google Repository is rev 36. You can try upgrading; it should resolve your problem.
Check if your Google Play Services version is the same (9.6.1) and update it also to the newest one or downgrade firebase version to the same:
compile 'com.google.android.gms:play-services:9.6.1'
Show us your build.gradle
To use firebase analytics you need a few things:
·Google play services package, rev 33
·Add this classpath in your project.gradle:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
·Add firebase core dependencie in app.gradle:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:9.6.1'
}
·Finally add pluguin at final of app.gradle:
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Then you can start to work with Firebase Analytics, you can find more info from sdk here, apply changes and rebuild project, tell me if you can use it with this changes, greetings!

Gradle Sync failed could not find constraint-layout:1.0.0-alpha2

Problem :
Error:Could not find com.android.support.constraint:constraint-layout:1.0.0-alpha2.
Required by:
myapp:app:unspecified
Background :
Android Studio 2.2 P 1
Support libraries for ConstraintLayout could not be installed/updated.
Just open Preferences > Appearance & Behavior > System Settings > Android and move to SDK Tools tab. Check the following fields and install.
In my case, that support libraries for ConstraintLayout were installed, but I was adding the incorrect version of ConstraintLayout Library in my build.gradle file. In order to see what version have you installed, go to Preferences > Appearance & Behavior > System Settings > Android SDK. Now, click on SDK Tools tab in right pane. Check Show Package Details and take note of the version.
Finally you can add the correct version in the build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
testCompile 'junit:junit:4.12'
}
The fix is to update the android gradle plugin in your build.gradle.
This should work:
classpath 'com.android.tools.build:gradle:2.2.0-alpha2'
Or you can use the latest:
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
My problem was, that the SDK Tools updated it to the latest version, in my case it was 1.0.0-alpha9, but in my gradle dependency was set to
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
So, you can change your gradle build file to
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
Or you check "Show package details" in the SDK Tools Editor and install your needed version. See screenshow below. Image of SDK Tools
Ensure you have the maven.google.com repository declared in your module-level build.gradle file
repositories {
maven {
url 'https://maven.google.com'
}
}
2.Add the library as a dependency in the same build.gradle file:
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
I updated my android gradle plugin to 2.2.0-alpha4 and constraint layout dependency to 1.0.0-alpha3 and it seems to be working now
First I tried everything that I have read on stackoverflow...from updating gradle to XY version, to updating ConstraintLayout to XY version...I even update my SDK tools and Android Studio to the latest version...but nothing was working.
The only solution that worked for me was that I delete ConstraintLayout library from gradle and SDK, then I opened random xml layout and in Design view under Palette section search for ConstraintLayout. If you have successfully deleted library from your project then you will be able to install the library from there if you double clicked on ConstraintLayout element.
That has create next line in my app build.gradle:
'com.android.support.constraint:constraint-layout:1.0.0-beta1'
In my project build.gradle I have this:
classpath 'com.android.tools.build:gradle:2.2.2'
Android studio version 2.2.2
Alpha version is no longer available !
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
Just to make sure that in studio version 2.3 you won't see a dropdown near constraint-layout in sdk tools, it will by default install the latest version
To get the desired version check the box saying show package details and boom you can now choose the desired version you want to install
gradle com.android.tools.build:gradle:2.2.0-alpha6
constraint layout dependency com.android.support.constraint:constraint-layout:1.0.0-alpha4
works for me
For me it was a completely different issue. When I installed constraint dependancy in SDK tools, the tools somehow wrote them into the wrong directory. That is
/home/${USER}/Android/Sdk/extras/+m2repository+/com/.../constraint
instead of
/home/${USER}/Android/Sdk/extras/+android+/+m2repository+/com/.../constraint
Remedy:
Just copy the 1.0.0-alpha* directories into the latter path
While updating SDK tools, a dilog box presented with Constraint layout version that is going to get installed. Note that and update your dependency based on that. In my case it was installing beta3.
I changed my dependency like below. After that it worked.
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3'
In my case, I had to remove the previous versions first and download the latest one instead. v1.0 stable was released on Feb 23rd.
In my case, I had a multi-module project called "app" and "sdk". The "sdk" module is the one where I had added the constraint layout library. I got the error when I tried to incorporate "sdk" into a new multi-module project called "app2". The solution was to ensure I had added the Google Maven Repository to the project-level build.gradle file for "app2". The Google Maven Repository can be added by putting "google()" under allprojects.repositories in the project-level build.gradle file:
allprojects {
repositories {
jcenter()
google()
}
}
In my case, I was using AS 2.3 and I wanted to use the currently latest ConstraintLayout 1.1.3, but the latest version in my Preferences > Appearance & Behavior > System Settings > Android was 1.0.2.
To use ConstraintLayout 1.1.3, I updated my AS from 2.3 to currently latest 3.2.1, com.android.tools.build:gradle from 2.2.2 to 3.2.1, gradle from 3.3 to 4.6 and buildToolsVersion from 25.0.0 to 28.0.3.
I also added maven { url 'https://maven.google.com' } to the Maven repositories in the project-level build.gradle file and that solved my problem.
Just as a heads up to those still searching for this.
ConstraintLayout 1.0.1 and lower have been deprecated by maven.
For a list of available constraint layouts that can be downloaded, see below:
https://maven.google.com/web/index.html?q=Constrain#com.android.support.constraint:constraint-layout
The easiest solution at the moment, is to change
implementation 'com.android.support.constraint:constraint-layout:1.0.0-beta1'
to
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
I used com.android.support.constraint:constraint-layout:1.0.0-alpha2 with classpath 'com.android.tools.build:gradle:2.1.0', it worked like charm.
Not sure if I'm too late, but in case someone has still the error after an update of ConstraintLayout and Solver over the SDK Tools, maybe this solution could help: Error:(30, 13) Failed to resolve: com.android.support.constraint:constraint-layout:1.0.0-alpha4
Its available in androidx as following package
implementation "androidx.constraintlayout:constraintlayout:2.0.0-alpha1"
Update your constraint layout dependency to the relevant version from '1.0.0-alpha2'. In my case, I changed to the following.
compile 'com.android.support.constraint:constraint-layout:2.0.0-alpha5'
I added the following script in build.gradle(app) under android & I was able to compile.
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
Similar issue solved by Reinstalling Android Studio.
i'm try constraint layout dependency update available 1,and plugin gradle alpha-6,it worked

Failed to resolve: com.google.firebase:firebase-core:9.0.0

I get the following error while upgrading a firebase project from old domain to new google firebase domain.
Failed to resolve: com.google.firebase:firebase-core:9.0.0
I followed the steps mentioned on the Firebase documentation, in the section Add Firebase to your Android Project, topic Available libraries.
What are my options to resolve this error?
Update Aug 2017
As of version 11.2.0 Firebase and Google Play services dependencies are available via Google's Maven Repo. You no longer need to use the Android SDK manager to import these dependencies.
In your root build.gradle file add the repo:
allprojects {
repositories {
// ...
maven { url "https://maven.google.com" }
}
}
If you are using gradle 4.0 or higher you can replace maven { url "https://maven.google.com" } with just google().
The 9.0.0 version of Firebase was built using Google Play services 9.0 and is now available under the new packaging com.google.firebase:*
See Release Notes for Google Play services 9.0
https://developers.google.com/android/guides/releases#may_2016_-_v90
New versions of packages Google Play Services (rev 30) and Google Repository (rev 26) were just released in the SDK manager so it's likely you just need to update.
Downloading Google Play Services and Google Repository
From Android Studio:
Click Tools > Android > SDK Manager.
Click into the SDK Tools tab.
Select and install Google Play Services (rev 30) and Google Repository (rev 26). See the image below.
Sync and Build your project.
From IntelliJ IDEA:
As of April 2017, the latest versions of Google Play Services and Repository are listed below.
Click Tools > Android > SDK Manager.
Under the Packages panel, Look for the Extras.
Select and install Google Play Services (rev 39) and Google Repository (rev 46). See the image below.
Perform a gradle project sync and Build your project.
Go to Android SDK Manager and install the latest version of below two libraries
Google Play Services
Google Repository
Error:(30, 13) Failed to resolve: com.google.firebase:firebase-auth:9.6.1
If you ever get this error and you are using Android studio 2.2 that comes with firebase component integrated in it which has libraries version 9.6.0 by default and you are adding the latest dependencies like 9.6.1 . You might need to downgrade com.google.firebase:firebase-auth:9.6.1 to com.google.firebase:firebase-auth:9.6.0
Or check the library version of your pre-installed firebase and make sure it is of the same version with the new library you are trying to add or added to your project.
Tried all the above, use the Firebase Assistant! It is the simplest way to solve this. First remove all the dependencies you added to the build.gradle (using the manual method) and then in Android Studio:
Click Tools > Firebase to open the Assistant window.
It really is as easy as that.
Faced myself and seen several times in comments for similar questions - that even after installing "latest" Google Play Services and Google Repository still having the same issue.
The thing is that they may be latest for your current revision of Android SDK Tools, but not that latest your app build requires.
In such case make sure to install latest version of Android SDK Tools first, and probably Android SDK Platform-tools (both under Tools branch). Also please note you may need to go through this several times if you haven't updated for a long time (i.e. install latest Android SDK Tools and Android SDK Platform-tools, then restart Android SDK Manager, then repeat), since the updates seem to be going through some critical mandatory milestones and you cannot install the very latest if you currently have the revision which is pretty "old".
dependencies {
compile 'com.google.android.gms:play-services-maps:11.8.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile 'com.google.firebase:firebase-storage:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
Following are the prerequisites if you want to add firebase to your project.
For working with Firebase you should install Android Studio 1.5 or higher.
Download the latest Google Play services SDK from through Android SDK Manager.
The device should be running Android 2.3 (Gingerbread) or newer, and Google Play services 9.2.0 or newer.
I could only find out all this after hours of struggle.
Source: Adding Firebase to your Android App
If using command line tools, do
sdkmanager 'extras;google;m2repository'
sdkmanager 'extras;android;m2repository'
Need to Update
Android SDK : SDK Tools -> Support Repository -> Google Repository
After updating the Android SDK need to sync gradle build in Android studio.
In my case, on top of adding google() in repositories for the project level gradle file, I had to also include it in the app level gradle file.
repositories {
mavenLocal()
google()
flatDir {
dirs 'libs'
}
}
If all the above methods are not working then change implementation 'com.google.firebase:firebase-core:12.0.0' to implementation 'com.google.firebase:firebase-core:10.0.0' in your app level build.gradle file.
This would surely work.
I tried all the solutions and nothing worked for me. Changing gradle version worked for me.
I changed following inside gradle-wrapper.properties
from
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
Update October 2022
com.google.firebase-core has been deprecated in October 2022. Instead of firebase-core, use firebase-analytics or firebase-analytics-ktx.
The firebase-core library is deprecated and no further versions will
be released. This SDK included the Firebase SDK for Google Analytics.
Now, to use Google Analytics or a product that recommends adding
Google Analytics, you need to explicitly declare the Analytics
dependency: com.google.firebase:firebase-analytics or
com.google.firebase:firebase-analytics-ktx.
Release notes

Categories

Resources