Glide 4.9.0无法使用MyAppGlideModule加载Firebase图片

时间:2019-08-20 04:11:11

标签: android android-glide firebaseui

我使用Glide 4.9.0加载图片,但是我想加载Firebase图片,因此我创建了一个类MyAppGlideModule进行覆盖,然后清理项目并重建它,但是仍然无法使用GlideApp加载图片,MyAppGlideModule仍显示未使用。

我没有在代码中添加annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0',因为在我migrate to AndroidX之后,它将获得编译错误。

我该如何修复它,或者它可以显示火力地堡图片,谢谢。

这是我的MyAppGlideModule班:

@GlideModule
public class MyAppGlideModule extends AppGlideModule {

    @Override
    public void registerComponents(Context context, Glide glide, Registry registry) {
        registry.append(StorageReference.class, InputStream.class,
                new FirebaseImageLoader.Factory());
    }

}

这是我想在recyclerview中加载图片的地方:

StorageReference pathReference = FirebaseStorage.getInstance().getReference().child(post.img);

                Glide.with(mContext)
                        .load(pathReference)
                        .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
                        .placeholder(R.drawable.ic_load_img)
                        .into(((PostViewHolder) holder).postcard_img);

这是我的bulide.gradle:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.browser:browser:1.0.0'
    implementation 'com.android.billingclient:billing:2.0.2'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'com.github.chrisbanes:PhotoView:2.1.4'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'com.github.bumptech.glide:annotations:4.9.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.firebase:firebase-core:17.0.1'
    implementation 'com.google.firebase:firebase-auth:18.1.0'
    implementation 'com.google.firebase:firebase-storage:18.1.1'
    implementation 'com.google.firebase:firebase-database:18.0.1'
    implementation 'com.google.firebase:firebase-messaging:19.0.1'
    implementation 'com.google.firebase:firebase-ads:18.1.1'
    implementation 'com.firebaseui:firebase-ui-storage:5.0.0'
    implementation 'com.facebook.android:audience-network-sdk:5.4.1'
    implementation 'com.facebook.android:facebook-android-sdk:5.4.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation files('libs/jsch-0.1.55.jar')
}

如果我在build.grade中添加annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0',我将得到以下错误代码:

C:/Users/Myapp/AndroidStudioProjects/PGapp  
app/build/generated/source/apt/debug/com/gmpsykr/goma/GlideOptions.java 
error: package android.support.annotation does not exist    
error: package android.support.annotation does not exist    
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
error: cannot find symbol class CheckResult 
app/build/generated/source/apt/debug/com/gmpsykr/goma/GlideRequest.java 
app/build/generated/source/apt/debug/com/gmpsykr/goma/GlideRequests.java    
app/build/generated/source/apt/debug/com/bumptech/glide/GeneratedRequestManagerFactory.java 
app/build/generated/source/apt/debug/com/bumptech/glide/GeneratedAppGlideModuleImpl.java    

1 个答案:

答案 0 :(得分:0)

我找到了解决方法,添加

implementation "com.android.support:support-annotations:28.0.0"
annotationProcessor "com.android.support:support-annotations:28.0.0"

似乎Glide 4.9.0还不支持AndroidX。