zoukankan      html  css  js  c++  java
  • Glide升级到4.x版本遇到的问题

     

    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();
    
     
  • 相关阅读:
    MD5验签同一字符串得到不同的MD5签名值可能问题之一
    Git本地仓库与远程github同步的时候提示fatal: remote origin already exists 错误解决办法
    SVN Error: Unreadable path encountered; access denied;
    2018年终个人总结
    ant编译无法依赖rt.jar
    ORA-00980: 同义词转换不再有效
    二叉树的深度和广度优先遍历
    Missing HTTP Strict-Transport-Security Header (HSTS) 解决
    单例模式
    sql 替换字段中部分内容
  • 原文地址:https://www.cnblogs.com/yelanggu/p/10831516.html
Copyright © 2011-2022 走看看