Cannot able to use StorageRefrence in my android app

Viewed 167

I am using Firebase for uplodaing the images but whenever i am using StorageReference then it saying cannot able to resolve this symbol i have tried to add dependency of storage but it is also not adding and giving me the error. Please tell how can i use StorageReference

my build.gradle(app):

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
    applicationId "example.example1.adminshayariapp"
    minSdkVersion 16
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-database:16.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.squareup.picasso:picasso:2.71828'

}

build.gradle(Project):

buildscript {

repositories {
    google()
    jcenter()
    
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.6.1'
    classpath 'com.google.gms:google-services:4.2.0'


    // 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

}

Please tell what is wrong why i am not able to use StorageReference.

1 Answers

If you are planning on using the Storage Bucket feature from Firebase I notice you are missing some implementations in your App Gradle:

  implementation 'com.google.firebase:firebase-storage:19.1.1'
  implementation 'com.google.firebase:firebase-auth:19.3.1' 

You might not need the second one, but i would recommend authentication anyway. Go ahead and add these into your dependencies, that should solve the issue. If it persists let me know and I'll give it a second look.

Also ensure that you have connected your app to your Firebase project...

In android studio, if you go to tools(top bar) > FireBase > Storage it will guide you through the installation, and ensure that you have all the dependencies you need.

enter image description here

Related