[java] Failed to resolve: com.google.firebase:firebase-core:16.0.1

I'm trying to add firebase cloud storage to my app. Below is the app build.gradle. But it says: Failed to resolve: com.google.firebase:firebase-core:16.0.1. Why? There is no firebase-core in the dependencies at all.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.louise.udacity.mydict"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    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.cloud:google-cloud-storage:1.31.0'
    implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
}

apply plugin: 'com.google.gms.google-services'

This question is related to java android firebase gradle android-gradle-plugin

The answer is


From the docs:-

Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.

Add:

 implementation 'com.google.firebase:firebase-core:16.0.1'

and in top level gradle file use the latest version of google play services:

classpath 'com.google.gms:google-services:4.0.2'

https://firebase.google.com/support/release-notes/android

https://bintray.com/android/android-tools/com.google.gms.google-services

Note:

You need to add the google() repo in the top level gradle file, as specified in the firebase docs and also it should be before jcenter():

 buildscript {
  repositories {
          google()
          jcenter()
      }



dependencies {
  classpath 'com.android.tools.build:gradle:3.1.3'
  classpath 'com.google.gms:google-services:4.0.2'
   }
}

allprojects {
     repositories {
              google()
             jcenter()
  }
}

task clean(type: Delete) {
  delete rootProject.buildDir
 }

https://firebase.google.com/docs/android/setup


As @Peter Haddad mentioned above,

To fix this issue I followed Google firebase integration guidelines and did the following changes in my app/build.gradle and project/build.gradle

Follow below mentioned link if you have any doubts

https://firebase.google.com/docs/android/setup

changes in app/build.gradle

_x000D_
_x000D_
implementation 'com.google.android.gms:play-services-base:15.0.2'_x000D_
implementation "com.google.firebase:firebase-core:16.0.1"_x000D_
implementation "com.google.firebase:firebase-messaging:17.4.0"
_x000D_
_x000D_
_x000D_

Changes in Project/build.gradle

_x000D_
_x000D_
repositories {_x000D_
_x000D_
        google()_x000D_
        jcenter()_x000D_
        mavenCentral()_x000D_
        maven {_x000D_
            url 'https://maven.fabric.io/public'_x000D_
        }_x000D_
    }_x000D_
    dependencies {_x000D_
        classpath 'com.android.tools.build:gradle:3.1.4'_x000D_
        classpath 'com.google.gms:google-services:4.2.0'// // google-services plugin it should be latest if you are using firebase version 16.0 +_x000D_
       _x000D_
    }_x000D_
    allprojects {_x000D_
    repositories {_x000D_
         google()// add it to top instead of bottom or somewhere in middle_x000D_
        mavenLocal()_x000D_
        mavenCentral()_x000D_
        maven {_x000D_
            url 'https://maven.google.com'_x000D_
        }_x000D_
       _x000D_
        jcenter()_x000D_
        maven {_x000D_
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm_x000D_
            url "$rootDir/../node_modules/react-native/android"_x000D_
        }_x000D_
        _x000D_
    }_x000D_
}
_x000D_
_x000D_
_x000D_


Since May 23, 2018 update, when you're using a firebase dependency, you must include the firebase-core dependency, too.

If adding it, you still having the error, try to update the gradle plugin in your gradle-wrapper.properties to 4.5 version:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip

and resync the project.


Add maven { url "https://maven.google.com" } to your root level build.gradle file

repositories {
    maven { url "https://maven.google.com" }
    flatDir {
        dirs 'libs'
    }
}

I get the same issue and i solved it by replacing :

implementation 'com.google.firebase:firebase-core:16.0.1'

to

implementation 'com.google.firebase:firebase-core:15.0.2'

and everything solved and worked well.


What actually was missing for me and what made it work then was downloading'Google Play services' and 'Google Repository'

Go to: Settings -> Android SDK -> SDK Tools -> check/install Google Play services + repository

SDK Tools Settings SS

Hope it helps.


This is rare, but there is a chance your project's gradle offline mode is enable, disable offline mode with the following steps;

  • In android studio, locate the file tab of the header and click
  • In the drop own menu, select settings
  • In the dialog produced, select "Build, Execution, Deploy" and then select "Gradle"
  • Finally uncheck the "offline work" check box and apply changes

If this doesn't work leave a comment describing your Logcat response and i'll try to help more.


I was able to solve the issue by following these steps-

1.) This error occurs when you didn't connect your project to firebase. Do that from Tools->Firebase if you are using Android studio version 2.2 or above.

2.) Make sure you have replaced the compile with implementation in dependencies in app/build.gradle

3.) Include your firebase dependency from the firebase docs. Everything should work fine now


Go to

Settings -> Android SDK -> SDK Tools ->

and make sure you install Google Play Services


If you receive an error stating the library cannot be found, check the Google maven repo for your library and version. I had a version suddenly disappear and make my builds fail.

https://maven.google.com/web/index.html


In my case it was resolved by changing the compileSdkVersion and targetSdkVersion from 26 to 27


Just add below code and update all firebase versions that will work

 implementation 'com.google.firebase:firebase-core:17.2.0'

If you use Firebase in a library module, you need to apply the google play services gradle plugin to it in addition to the app(s) module(s), but also, you need to beware of version 4.2.0 (and 4.1.0) which are broken, and use version 4.0.2 instead.

Here's the issue: https://github.com/google/play-services-plugins/issues/22


if you are using

compileSdkVersion 23

in app-level gradle, and

classpath 'com.android.tools.build:gradle:2.1.0'

in project-level gradle and you have added the google-services.json file to your project.

you need to add just below code

maven {
   url "https://maven.google.com"
}

at below of jcenter() in repositories blocks in project-level gradle file here are my gradle files:

project-level gradle file:

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.google.gms:google-services:4.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

and app-level gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.moslem.amazonlikeapp"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'

Questions with java tag:

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error Instantiating a generic type When to create variables (memory management) java doesn't run if structure inside of onclick listener String method cannot be found in a main class method Are all Spring Framework Java Configuration injection examples buggy? Calling another method java GUI I need to know how to get my program to output the word i typed in and also the new rearranged word using a 2D array Java and unlimited decimal places? Read input from a JOptionPane.showInputDialog box Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable Two Page Login with Spring Security 3.2.x Hadoop MapReduce: Strange Result when Storing Previous Value in Memory in a Reduce Class (Java) Got a NumberFormatException while trying to parse a text file for objects Best way for storing Java application name and version properties Call japplet from jframe FragmentActivity to Fragment Comparing two joda DateTime instances Maven dependencies are failing with a 501 error IntelliJ: Error:java: error: release version 5 not supported Has been compiled by a more recent version of the Java Runtime (class file version 57.0) Why am I getting Unknown error in line 1 of pom.xml? Gradle: Could not determine java version from '11.0.2' Error: Java: invalid target release: 11 - IntelliJ IDEA Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Why is 2 * (i * i) faster than 2 * i * i in Java? must declare a named package eclipse because this compilation unit is associated to the named module How do I install Java on Mac OSX allowing version switching? How to install JDK 11 under Ubuntu? Java 11 package javax.xml.bind does not exist IntelliJ can't recognize JavaFX 11 with OpenJDK 11 Difference between OpenJDK and Adoptium/AdoptOpenJDK OpenJDK8 for windows How to allow all Network connection types HTTP and HTTPS in Android (9) Pie? Find the smallest positive integer that does not occur in a given sequence Error: JavaFX runtime components are missing, and are required to run this application with JDK 11 How to uninstall Eclipse? Failed to resolve: com.google.firebase:firebase-core:16.0.1 How to resolve Unable to load authentication plugin 'caching_sha2_password' issue

Questions with android tag:

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks Why am I seeing net::ERR_CLEARTEXT_NOT_PERMITTED errors after upgrading to Cordova Android 8? "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' GoogleMaps API KEY for testing Can I use library that used android support with Androidx projects. How to allow all Network connection types HTTP and HTTPS in Android (9) Pie? Android Material and appcompat Manifest merger failed Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 How to format DateTime in Flutter , How to get current time in flutter? How to change package name in flutter? Failed to resolve: com.android.support:appcompat-v7:28.0 What is AndroidX? Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve FirebaseInstanceIdService is deprecated installation app blocked by play protect Handling back button in Android Navigation Component Android design support library for API 28 (P) not working Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Install Android App Bundle on device Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. How to develop Android app completely using python? Invoke-customs are only supported starting with android 0 --min-api 26 Flutter.io Android License Status Unknown How to open Android Device Monitor in latest Android Studio 3.1 Default interface methods are only supported starting with Android N How can I change the app display name build with Flutter? Error:(9, 5) error: resource android:attr/dialogCornerRadius not found error: resource android:attr/fontVariationSettings not found Flutter does not find android sdk Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0) Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior flutter run: No connected devices Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation' PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT (in windows 10)

Questions with firebase tag:

How can I solve the error 'TS2532: Object is possibly 'undefined'? Getting all documents from one collection in Firestore FirebaseInstanceIdService is deprecated Failed to resolve: com.google.firebase:firebase-core:16.0.1 NullInjectorError: No provider for AngularFirestore Firestore Getting documents id from collection How to update an "array of objects" with Firestore? firestore: PERMISSION_DENIED: Missing or insufficient permissions Cloud Firestore collection count iOS Swift - Get the Current Local Time and Date Timestamp Error: fix the version conflict (google-services plugin) Enabling CORS in Cloud Functions for Firebase Error: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() Plugin with id 'com.google.gms.google-services' not found Didn't find class "com.google.firebase.provider.FirebaseInitProvider"? How to use Apple's new .p8 certificate for APNs in firebase console Convert Promise to Observable How to add SHA-1 to android application how to end ng serve or firebase serve How do you send a Firebase Notification to all devices via CURL? Class file for com.google.android.gms.internal.zzaja not found No notification sound when sending notification from firebase in android How do I detect if a user is already logged in Firebase? FCM getting MismatchSenderId Firebase (FCM) how to get token How to handle notification when app in background in Firebase What is FCM token in Firebase? Is it safe to expose Firebase apiKey to the public? Firebase Permission Denied How can I send a Firebase Cloud Messaging notification without use the Firebase Console? Firebase onMessageReceived not called when app in background Firebase cloud messaging notification not received by device Where can I find the API KEY for Firebase Cloud Messaging? How to get a list of all files in Cloud Storage in a Firebase app? Notification Icon with the new Firebase Cloud Messaging system Unable to get provider com.google.firebase.provider.FirebaseInitProvider Failed to resolve: com.google.firebase:firebase-core:9.0.0 Firebase TIMESTAMP to date and Time how to get all child list from Firebase android Android Firebase, simply get one child object's data MongoDB vs Firebase Firebase: how to generate a unique numeric ID for key? Query based on multiple where clauses in Firebase How to delete/remove nodes on Firebase In Firebase, is there a way to get the number of children of a node without loading all the node data? Firebase Storage How to store and Retrieve images

Questions with gradle tag:

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0) Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation' Execution failed for task ':app:compileDebugJavaWithJavac' Android Studio 3.1 Update Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_151 contains a valid JDK installation java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex in Android Studio 3.0 "The specified Android SDK Build Tools version (26.0.0) is ignored..." Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0 Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle Failed to resolve: com.android.support:appcompat-v7:26.0.0 Setting up Gradle for api 26 (Android) What's the difference between implementation and compile in Gradle? More than one file was found with OS independent path 'META-INF/LICENSE' Android Studio 3.0 Flavor Dimension Issue Jersey stopped working with InjectionManagerFactory not found Could not find com.android.tools.build:gradle:3.0.0-alpha1 in circle ci Gradle - Could not target platform: 'Java SE 8' using tool chain: 'JDK 7 (1.7)' Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details Error:Failed to open zip file. Gradle's dependency cache may be corrupt Error:Cause: unable to find valid certification path to requested target gradlew command not found? error: package com.android.annotations does not exist You have not accepted the license agreements of the following SDK components How do I activate a Spring Boot profile when running from IntelliJ? Difference between using gradlew and gradle Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Automatically accept all SDK licences Gradle Sync failed could not find constraint-layout:1.0.0-alpha2 Error:Conflict with dependency 'com.google.code.findbugs:jsr305' How to run bootRun with spring profile via gradle task The number of method references in a .dex file cannot exceed 64k API 17 How to set an environment variable from a Gradle build? Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease' No matching client found for package name (Google Analytics) - multiple productFlavors & buildTypes configuring project ':app' failed to find Build Tools revision "Gradle Version 2.10 is required." Error Gradle version 2.2 is required. Current version is 2.10 Difference between clean, gradlew clean How to downgrade to older version of Gradle Error:Unknown host services.gradle.org. You may need to adjust the proxy settings in Gradle Gradle Error:Execution failed for task ':app:processDebugGoogleServices' failed to find target with hash string android-23

Questions with android-gradle-plugin tag:

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Android Material and appcompat Manifest merger failed Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries Invoke-customs are only supported starting with android 0 --min-api 26 error: resource android:attr/fontVariationSettings not found Exception : AAPT2 error: check logs for details Could not resolve com.android.support:appcompat-v7:26.1.0 in Android Studio new project Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error) "The specified Android SDK Build Tools version (26.0.0) is ignored..." Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0 Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Android studio 3.0: Unable to resolve dependency for :app@dexOptions/compileClasspath': Could not resolve project :animators Gradle - Error Could not find method implementation() for arguments [com.android.support:appcompat-v7:26.0.0] Failed to resolve: com.android.support:appcompat-v7:26.0.0 No resource found that matches the given name: attr 'android:keyboardNavigationCluster'. when updating to Support Library 26.0.0 Failed to resolve: com.android.support:cardview-v7:26.0.0 android Android dependency has different version for the compile and runtime ionic 2 - Error Could not find an installed version of Gradle either in Android Studio Gradle error: Minimum supported Gradle version is 3.3. Current version is 3.2 Kotlin Error : Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7 Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK - Android Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored' error: package com.android.annotations does not exist Automatically accept all SDK licences Class file for com.google.android.gms.internal.zzaja not found Error:Conflict with dependency 'com.google.code.findbugs:jsr305' Could not find method android() for arguments Android Studio - Failed to apply plugin [id 'com.android.application'] The number of method references in a .dex file cannot exceed 64k API 17 Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease' Error: No toolchains found in the NDK toolchains folder for ABI with prefix: llvm configuring project ':app' failed to find Build Tools revision "Gradle Version 2.10 is required." Error Gradle version 2.2 is required. Current version is 2.10 Android Studio Gradle: Error:Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package Error "File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it" Error:Execution failed for task ':app:transformClassesWithDexForDebug' Error:Unknown host services.gradle.org. You may need to adjust the proxy settings in Gradle Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ Error: Execution failed for task ':app:clean'. Unable to delete file HttpClient won't import in Android Studio Android Gradle Apache HttpClient does not exist? Error running android: Gradle project sync failed. Please fix your project and try again Could not find or load main class org.gradle.wrapper.GradleWrapperMain Execution failed for task ':app:compileDebugAidl': aidl is missing finished with non zero exit value Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to Error:Execution failed for task ':ProjectName:mergeDebugResources'. > Crunching Cruncher *some file* failed, see logs