【问题标题】:Glide cannot resolve method 'signature(StringSignature)'Glide 无法解析方法'signature(StringSignature)'
【发布时间】:2018-08-20 16:01:25
【问题描述】:

我正在使用滑翔 4.3.1

我想调用签名方法但没有出现。

我的代码

Glide.with(context).load(context.getFilesDir().getPath() + "/" + imgName).into(imgView);

我想这样做

Glide.with(context).load(context.getFilesDir().getPath() + "/" + imgName).signature(new StringSignature("someVersion")).into(imgView);

我正在使用 android studio,当我将鼠标放在签名方法上时,我看到消息:无法解析方法'signature(StringSignature)'。

我的构建等级:

dependencies {
  compile 'com.github.bumptech.glide:glide:4.3.1'
}

【问题讨论】:

    标签: android caching signature android-glide


    【解决方案1】:

    在 glide v4 中,您应该使用ObjectKey(用于文件和网址)或MediaStoreSignature(用于媒体内容)而不是StringSignature

    【讨论】:

      【解决方案2】:

      你需要把它放在你的应用程序 gradle 中

      实现'com.github.bumptech.glide:glide:4.9.0'

      annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

      在你的代码中你必须把这个

      GlideApp.with(context)
                  .load(file.getAbsolutePath())
                  .signature(new ObjectKey(file.getPath() + file.lastModified()))
                  .fitCenter()
                  // caches only the final image, after reducing the resolution
                  .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
                  .into(view); 
      

      【讨论】:

        【解决方案3】:

        据我了解,您为 Glide 编写了扩展类,但您使用的是基本 Glide 类。你应该使用Glide generated API

        GlideApp.with(fragment)
           .load(myUrl)
           .placeholder(R.drawable.placeholder)
           .signature(new StringSignature("someVersion")) // your extension 
           .into(imageView);
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-07-03
          • 2021-05-07
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多