mystic cola
mystic cola

Reputation: 1643

Android Glide "Cannot Resolve Method 'with' in GlideApp"

I've read lots of other posts on this, and I've read the explanation on Bumptech. But something's still not clicking with me. I've got the following code:

if (image != null) {
            GlideApp
                    .with(this)
                    .load(imageUrl)
                    .centerCrop()
                    .transition(withCrossFade())
                    .into(eventImageView);
        }

Which returns the error above: Cannot Resolve Method 'with' in 'GlideApp'.

I followed the first answer in this question:

Glide showing error: Failed to find GeneratedAppGlideModule

...but it doesn't seem to change anything:

import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;

@GlideModule
public class GlideApp extends AppGlideModule {

}

lastly my app build.gradle:

implementation ("com.github.bumptech.glide:glide:4.11.0") {
        exclude group: "com.android.support"
    }
    annotationProcessor 'androidx.annotation:annotation:1.1.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    implementation ("com.github.bumptech.glide:glide:4.11.0@aar") {
        transitive = true
    }

Don't understand why Glide suddenly became so complicated...

Upvotes: 1

Views: 4631

Answers (4)

Nikola Djokic
Nikola Djokic

Reputation: 113

I have found that when I experience this error, in 99% of cases it is that build fails somewhere else, so GlideApp is not generated. But Android studio does not always reports the original error. It can be very frustrating.

What helps me to source the problem is code inspection(Analyze->Inspect Code), then fix all other errors. Also gradlew with --stacktrace and --scan

Invalidating cache/restart can help, especially after making some changes.

If you are using Room pay special attention to Daos. Android studio will not report some errors.

Upvotes: 0

Sienna
Sienna

Reputation: 1

try adding this to your build.gradle:

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

Upvotes: 0

ADITYA RANADE
ADITYA RANADE

Reputation: 293

Is the image View inside a fragment ? If yes then change it to Glide.with(getContext()).load(imageUrl).centerCrop().transition(withCrossFade()).into(eventImageView);

Upvotes: 0

mystic cola
mystic cola

Reputation: 1643

According to the latest instructions you don't actually need to do ANY of the stuff from the link in the question. You just use "Glide" as normal and you don't have to use "GLideApp".

repositories {
  google()
  jcenter()
}

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.12.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
}

It also doesn't look like you need to setup a custom class or anything like that.

So I reverted to my old code:

Glide
                .with(this)
                .load(imageUrl)
                .centerCrop()
                .transition(withCrossFade())
                .into(eventImageView);
    }

Upvotes: 2

Related Questions