I encountered two problems loading online pictures using glide version today
Failed to find GeneratedAppGlideModule
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. The dependent Glide version is
/ / glide implementation (' com. Making. Bumptech. Glide: glide: 4.8.0 ') {exclude group: Com. Android. "support"} annotationProcessor 'com. Making. Bumptech. Glide: the compiler: 4.8.0'Copy the code
A review of the official documentation shows that the 4.x version of Glide calls the interface quite differently than it did before 4.x.
In the Github issue, find the following answer:
To use the generated API in your application, you need to perform two steps: 1. Add a dependency on Glide's annotation Processor: Dependencies ` ` ` repositories {mavenCentral ()} {annotationProcessor 'com. Making. Bumptech. Glide: the compiler: 4.8.0'} ` ` ` 2. Include a [`AppGlideModule`] ``` package com.example.myapp; import com.bumptech.glide.annotation.GlideModule; import com.bumptech.glide.module.AppGlideModule; @glidemodule public final class MyAppGlideModule extends AppGlideModule {} ' 'You're not required to implement any of the methods in `AppGlideModule` for the API to be generated. You can leave the class blank as long as it extends `AppGlideModule` and is annotated with `@GlideModule`.Copy the code
After adding the AppGlideModule as documented, the problem is resolved.
The asBitmap() interface was not found
After checking the documentation, I found that the interface of 4.x had changed
for anyone came here and still have this issue, I found the way to fix it,
you must add the asBitmap() right After with() and it will work just like old times
Copy the code
The code can be solved after the following modifications:
// Put asBitmap() right after Glide.with(context) for glide 4.x Glide.with(mActivity).asBitmap() .load(url) .listener(new RequestListener<Bitmap>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Bitmap> target, boolean b) { return false; } @Override public boolean onResourceReady(Bitmap bitmap, Object o, Target<Bitmap> target, DataSource dataSource, boolean b) { Log.d(TAG, "get serialNo : " + serialNo + " cover successful!" ); if (mPreviewingFaceMap.containsKey(serialNo)) { mPreviewingFaceMap.get(serialNo).activityCoverBitmap = bitmap; } return false; } } ).submit();Copy the code
Due to the lack of time today, WE have not had a thorough understanding of the above two problems. Here we only record the solutions. I will take a closer look at the interface changes for Glide4.0 and the Generated API concepts mentioned in the official documentation.