Glide showing error: Failed to find GeneratedAppGlideModule

前端 未结 6 1328
小鲜肉
小鲜肉 2020-12-05 09:37

I am trying to load an image using glide but somehow I can not load the image using glide. As it shows following error:

Failed to find GeneratedAppGli

6条回答
  •  旧时难觅i
    2020-12-05 10:15

    Finally, I found my answer here.

    What I have done :

    Step-1

    I created an empty class named GlideApp

    import com.bumptech.glide.annotation.GlideModule;
    import com.bumptech.glide.module.AppGlideModule;
    
    @GlideModule
    public class GlideApp extends AppGlideModule {
    
    }
    

    Note: Don't forget to add annotation @GlideModule.

    Step-2 After that, I build/rebuild the project and then, replaced Glide with GlideApp.and now no need to use RequestOptions.

    public class CustomBindingAdapter {
    
        @BindingAdapter({"bind:image_url"})
        public static void loadImage(ImageView imageView, String url) {
    
    //        RequestOptions requestOptions = new RequestOptions();
    //        requestOptions=requestOptions.placeholder(R.drawable.boy_32);
    
            GlideApp.with(imageView.getContext())
                    .load(url)
                    .placeholder(R.drawable.boy_32)
                    .into(imageView);
    
    //            Glide.with(imageView.getContext())
    //                    .load(url)
    //                    .apply(requestOptions)
    //                    .into(imageView);
        }
    }
    

    Edit: For androidx and Glide versin 4.9.0:

    In my app's gradle.build:

    implementation ("com.github.bumptech.glide:glide:4.9.0") {
        exclude group: "com.android.support"
    }
    annotationProcessor 'androidx.annotation:annotation:1.0.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    implementation ("com.github.bumptech.glide:glide:4.9.0@aar") {
        transitive = true
    }
    

    In my gradle.properties:

    android.enableJetifier=true
    android.useAndroidX=true
    

    That's all.

提交回复
热议问题