3

I have the code:

  Glide.with(getActivity())
  .load(myurl)
  .asGif()
  .into(ivGif);

and I imported glide in gradle:

  repositories {
  mavenCentral()
  maven { url 'https://maven.google.com' }
  }

dependencies {
  compile 'com.github.bumptech.glide:glide:4.2.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
}

Compiler says

cannot resolve method .asGif()

Do I miss something?

Vasile Doe
  • 1,674
  • 1
  • 24
  • 40

1 Answers1

5

On older versions of Glide you can use like this:

GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView, LOOP_COUNT);
Glide.with(mContext)
    .load(yourgif)
    .into(imageViewTarget);

As of Glide version 4.x, asGif() method is removed. You can handle gif just like this:

Glide.with(mContext)
    .load(yourgif)
    .into(imageView);
Oğuzhan Döngül
  • 7,856
  • 4
  • 38
  • 52
  • please gife code for GlideDrawableImageViewTarget class – Dika Feb 23 '19 at 04:51
  • 1
    @Dika My answer is a bit outdated. After Glide upgrades v4, this class has been removed. You can check this answer to find an alternative to GlideDrawableImageTarget. https://stackoverflow.com/a/51531284/3669559 – Oğuzhan Döngül Feb 23 '19 at 07:42
  • 1
    @Dika I was thinking about updating my answer when I am available but you changed my answer entirely. I made my answer more comprehensive. Still some people use older versions of Glide library. – Oğuzhan Döngül Feb 23 '19 at 09:27
  • Thanks @OğuzhanDöngül this should be the accepted answer. – Shashi Shiva L Oct 04 '21 at 12:17