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 GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored.
I have reffered This solution too. But, I already have the updated verion of glide.
In my gradle, I have added
implementation 'com.github.bumptech.glide:glide:4.7.1'
and
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
Code
XML
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".view.SettingActivity">
<data>
<variable
name="settingsViewModel"
type="com.sevenbits.android.mvvmsample.viewmodel.SettingsViewModel"/>
</data>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash_bg">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="@color/white"
android:elevation="10dp"
android:orientation="vertical"
android:padding="5dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_margin="10dp"
app:image_url="@{settingsViewModel.imageUrl}"
app:civ_border_width="2dp"
app:civ_border_color="@color/colorPrimary"/>
...
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>
CustomBindingAdapter
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);
Glide.with(imageView.getContext())
.load(url)
.apply(requestOptions)
.into(imageView);
}