Reputation: 3279
I am using Glide library to load images in android earlier Glide was loading images easily but now it is showing error though image url are showing in log cat but unable to load in image view.
It is showing below 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
build.gradle
apply plugin: 'com.android.application'
repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.app.bookbudiapp"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
apply plugin: 'com.google.gms.google-services'
MyGlideApp
@GlideModule
public class MyGlideApp extends AppGlideModule {}
HomeOfferAdapter.java
public class HomeOfferAdapter extends PagerAdapter {
private Context context;
private LayoutInflater layoutInflater;
private List<HomeOffersModel> banners;
public HomeOfferAdapter(List<HomeOffersModel> banners,Context context){
this.banners = banners;
this.context = context;
}
@Override
public int getCount() {
return banners.size();
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object o) {
return view == o;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert layoutInflater != null;
View view = layoutInflater.inflate(R.layout.onboard_frag,container,false);
ImageView slideImage = view.findViewById(R.id.offerImage);
HomeOffersModel model = banners.get(position);
// RequestOptions options = new RequestOptions();
// options.placeholder(R.drawable.openbook);
GlideApp.with(context).load(model.getOffers()).placeholder(R.drawable.openbook).into(slideImage);
container.addView(view);
return view;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView((LinearLayout)object);
}
}
Error after rebuilding project:
Caused by: java.lang.NullPointerException
at com.bumptech.glide.annotation.compiler.ProcessorUtil.findInstanceMethodsReturning(ProcessorUtil.java:474)
at com.bumptech.glide.annotation.compiler.RequestOptionsOverrideGenerator.generateInstanceMethodOverridesForRequestOptions(RequestOptionsOverrideGenerator.java:49)
at com.bumptech.glide.annotation.compiler.RequestOptionsOverrideGenerator.generateInstanceMethodOverridesForRequestOptions(RequestOptionsOverrideGenerator.java:41)
at com.bumptech.glide.annotation.compiler.RequestOptionsGenerator.generate(RequestOptionsGenerator.java:157)
at com.bumptech.glide.annotation.compiler.AppModuleProcessor.maybeWriteAppModule(AppModuleProcessor.java:87)
at com.bumptech.glide.annotation.compiler.GlideAnnotationProcessor.process(GlideAnnotationProcessor.java:131)
at org.gradle.api.internal.tasks.compile.processing.DelegatingProcessor.process(DelegatingProcessor.java:62)
at org.gradle.api.internal.tasks.compile.processing.AggregatingProcessor.process(AggregatingProcessor.java:50)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
... 69 more
Someone please let me know what I am doing wrong. Any help would be appreciated.
THANKS
Upvotes: 2
Views: 9726
Reputation: 3502
According to the documentation from Glide on GitHub:
repositories {
mavenCentral()
google() // You were missing this
}
dependencies {
implementation 'com.github.bumptech.glide:glide:4.9.0' //bumped from 4.8.0 to 4.9.0
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
Always make sure to use the latest version. It was being caused due to missing google()
repository in your project level gradle file.
Upvotes: 3
Reputation: 289
try to rebuild the project and use GlideApp instead of Glide like following code:
GlideApp.with(context).load(model.getOffers).apply(options).into(slideImage);
Upvotes: 0