Error: In adding Firebase Storage dependency to Android Studio Project?
Error: In adding Firebase Storage dependency to Android Studio Project?
I have created a Firestore Project in Android Studio. In which I have Firebase Authorization implemented and that is working absolutely fine. I am able to push documents to Firestore Database.
But now, I am trying to add functionality using which I can store media/images to Firebase Storage but when I am adding this dependency to app's build.gradle file, I am getting this error:
Dependency added:
implementation 'com.google.firebase:firebase-storage:16.0.1'
This is the error that I am getting:
Could not find firebase-common.jar (com.google.firebase:firebase-common:16.0.0).
Searched in the following locations:https://jcenter.bintray.com/com/google/firebase/firebase-common/16.0.0/firebase-common-16.0.0.jar
FYI, In my project I already have this kind of configuration:
classpath 'com.android.tools.build:gradle:3.1.3'
And
apply plugin: 'com.google.gms.google-services'
I can not find what is going wrong when I just add firebase-storage dependency to my Android project.
Here is my app level build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.firebase.example"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
dependencies {
implementation 'com.google.firebase:firebase-firestore:16.0.0'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:23.2.1'
implementation 'com.android.support:design:23.2.1'
implementation 'com.android.support:recyclerview-v7:23.2.1'
}
apply plugin: 'com.google.gms.google-services'
Here is my module level build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
classpath 'com.google.android.gms:play-services-base:15.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
5 Answers
5
Have you added these to your root level gradle file?
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
}
}
You have to add dependencies {classpath 'com.google.gms:google-services:4.0.1'}
and repositories { google()}
on your root level build.gradle file. Have you added that? And further more please provide your whole build.gradle file in order to understand your problem .
dependencies {classpath 'com.google.gms:google-services:4.0.1'}
repositories { google()}
I have already added that.
– Master
Jun 29 at 11:50
Great what version you are using for auth?
– Brijesh Joshi
Jun 29 at 11:51
implementation 'com.google.firebase:firebase-auth:15.1.0'
– Master
Jun 29 at 11:55
In App gradle
implementation 'com.google.firebase:firebase-firestore:16.0.0' implementation 'com.google.firebase:firebase-auth:15.1.0' implementation 'com.google.firebase:firebase-storage:16.0.1' implementation 'com.google.android.gms:play-services-auth:15.0.1'
and in Root gradle classpath 'com.google.android.gms:play-services-base:15.0.1' classpath 'com.google.gms:google-services:4.0.1'
This worked well for me it successfully generated build– Brijesh Joshi
Jun 29 at 12:07
implementation 'com.google.firebase:firebase-firestore:16.0.0' implementation 'com.google.firebase:firebase-auth:15.1.0' implementation 'com.google.firebase:firebase-storage:16.0.1' implementation 'com.google.android.gms:play-services-auth:15.0.1'
classpath 'com.google.android.gms:play-services-base:15.0.1' classpath 'com.google.gms:google-services:4.0.1'
Adding firebase-storage to exactly this configuration gives me error: Failed to resolve: firebase-common
– Master
Jun 29 at 12:12
Upgrade the following:
implementation 'com.google.firebase:firebase-firestore:16.0.0'
implementation 'com.google.firebase:firebase-auth:15.1.0'
into this:
implementation 'com.google.firebase:firebase-firestore:17.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.2'
Check here for more info:
https://firebase.google.com/support/release-notes/android
Peter, I tried this and still I am getting error while building project.
– Master
Jun 29 at 12:02
what is the error that you are getting?
– Peter Haddad
Jun 29 at 12:03
Failed to resolve: firebase-database-collection Failed to resolve: protolite-well-known-types
– Master
Jun 29 at 12:04
add
implementation 'com.google.firebase:firebase-database:16.0.1'
– Peter Haddad
Jun 29 at 12:25
implementation 'com.google.firebase:firebase-database:16.0.1'
add the above dependency, then clean and rebuild
– Peter Haddad
Jun 29 at 15:31
Also you can use firebase assitant set up
I was able to make it work guys. You can simply compare my new gradle files. The issue was conflicting google services libraries and gradle version. So, I created new project and just added dependencies again like this and it worked.
So, I removed this from app/build.gradle:
implementation 'com.google.android.gms:play-services-auth:15.0.1'
And, removed this from module/build.gradle:
classpath 'com.google.android.gms:play-services-base:15.0.1'
and updated gradle version in module/build.gradle:
classpath 'com.google.gms:google-services:4.0.1'
New build.gradle files look like this.
module/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "master.firebasesetup"
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:support-v4:27.1.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.firebase:firebase-firestore:17.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Bijal, thank. That was already there but still I was getting errors.
– Master
Jun 29 at 12:24