reavcn
reavcn

Reputation: 310

Cannot resolve method using(com.firebase.ui.storage.images.FirebaseImageLoader)

I'm trying to use the awesome Glide integration provided by FirebaseUI, but I am unable to do so.

I have followed everything described here: Downloading images with FirebaseUI

Cannot resolve method using(com.ui.firebase.storage.images.FirebaseImageLoader)

is the error that I am currently getting.

Are my settings good?

Here are the versions of the two libraries I am using:

And this is my gradle (app):

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.firebase:geofire-android:2.1.1'
    compile 'com.google.android.gms:play-services-location:11.0.1'
    compile 'com.android.support:design:25.3.1'

    implementation 'com.google.firebase:firebase-database:11.0.1'
    implementation 'com.android.support:cardview-v7:25.3.1'
    compile 'com.firebaseui:firebase-ui-storage:2.0.1'
    compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
    compile 'com.android.support:support-v4:25.3.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
    implementation 'com.google.firebase:firebase-storage:11.0.1'
    implementation 'com.google.firebase:firebase-auth:11.0.1'

}

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

Upvotes: 7

Views: 6288

Answers (3)

Tork
Tork

Reputation: 496

You must include firebase-ui-storage in your Gradle dependencies (/app/build.gradle) as follows:

dependencies {

    implementation 'com.firebaseui:firebase-ui-storage:6.2.1'
}

Check: last version of this library

And then import the package:

import com.firebase.ui.storage.images.FirebaseImageLoader;

Upvotes: 2

user9606326
user9606326

Reputation:

That happend to me and I solved it with:

// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:3.3.0'
// Glide
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

Here is the MyAppGlideModule that needs to extend AppGlideModule. It is of vital importance to Override the "registerComponents" function:

@GlideModule
public final class MyAppGlideModule extends AppGlideModule {
  @Override
  public void registerComponents(Context context, Glide glide, Registry 
  registry) {
    // Register FirebaseImageLoader to handle StorageReference
    registry.append(StorageReference.class, InputStream.class,
            new FirebaseImageLoader.Factory());
}

}

And the function that actually downloads the image:

import com.app.path.where.the.myappglidemodule.is.GlideApp;
"Ex: import com.firebase.uidemo.storage.GlideApp  //In case MyAppGlideModule is inside storage package"

public void downloadDirect(StorageReference imageRef, ImageView imageView) {
    try {
        if (imageRef != null) {
            // Download directly from StorageReference using Glide
            // (See MyAppGlideModule for Loader registration)
            GlideApp.with(this)
                    .load(imageRef)
                    .centerCrop()
                    .transition(DrawableTransitionOptions.withCrossFade())
                    .into(imageView);
        } else {
            Log.e(TAG, "Null image storage reference!");
        }
    }catch (Exception ex){
        Log.e(TAG, ex.toString());
    }
}

Upvotes: 1

SUPERCILEX
SUPERCILEX

Reputation: 4007

Unfortunately, FirebaseUI doesn't yet support Glide 4.0 so you have two options:

  1. Downgrade Glide to v3.8.0
  2. Write your own Glide Module. You can see my response here on how you would go about upgrading the FirebaseUI storage code.

This issue is being tracked here: https://github.com/firebase/FirebaseUI-Android/issues/731

Edit: As per link above, the issue has been resolved in version 3.0

Upvotes: 6

Related Questions