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
Add maven { url "https://maven.google.com" } to your root level build.gradle file
repositories {
maven { url "https://maven.google.com" }
flatDir {
dirs 'libs'
}
}
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.
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
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.
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.
Just add below code and update all firebase versions that will work
implementation 'com.google.firebase:firebase-core:17.2.0'
Go to
Settings -> Android SDK -> SDK Tools ->
and make sure you install Google Play Services
This is rare, but there is a chance your project's gradle offline mode is enable, disable offline mode with the following steps;
If this doesn't work leave a comment describing your Logcat response and i'll try to help more.
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'
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
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_
Changes in Project/build.gradle
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_
In my case it was resolved by changing the compileSdkVersion and targetSdkVersion from 26 to 27
Source: Stackoverflow.com