Categories
Studio

Solution to “Cannot resolve symbol GlideApp” – Glide Library v4 error

I have been using Glide library for displaying images for my projects since 2015. This library saves too much of code and efforts. But this is not what it used to be back then.

To use the advanced features like placeholder(), centerCrop(), etc. you have to use GlideApp.

Glide v4 requires you to GlideApp use instead of just Glide. But some developers now (including me) face an error despite implementing the latest version and compiler in Gradle. So how can we solve this issue right away?

Implementation of this library is better showcased on code path in detail. But for the sake of simplicity, I’ll add the implementation method here.

How to Implement Glide Library

Add these lines to your app level Gradle file under dependencies

// glide
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'

How to solve “Cannot resolve symbol GlideApp”?

Well, it’s actually very simple to do so. It won’t work right away after implementing it right away. You need to create a new class MyAppGlideModule and extend AppGlideModule to it. Refer the code below.

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

// new since Glide v4
@GlideModule
public final class MyAppGlideModule extends AppGlideModule {
    // leave empty for now


}

Now go to Build > Make Project or simply press ⌘ + F9 (if you are on Mac). You won’t see the error message again.

Now you know how to make the latest version of Glide library work. Let me know in comments if this code doesn’t work for you.

This tutorial is based on short, self-contained, correct (compatible), example. Refer SSCCE.org

Leave a Reply

Your email address will not be published. Required fields are marked *