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.
依賴的glide版本是
// glide implementation ('com.github.bumptech.glide:glide:4.8.0') { exclude group: "com.android.support" } annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
查閱官方文檔之后發現,4.x版本的Glide在接口調用和4.x之前有很大區別。
在github的issue里,找到如下答案:
To use the generated API in your application, you need to perform two steps: 1. Add a dependency on Glide’s annotation processor: ``` repositories { mavenCentral() } dependencies { annotationProcessor 'com.github.bumptech.glide: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`.
按照文檔,添加AppGlideModule之后,問題解決。
asBitmap() 接口找不到了
查閱文檔后發現是4.x的接口變動了
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
代碼做如下修改后解決:
// 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();