Android Studio 3.x: error: cannot find symbol class GlideApp

Viewed 15288

I updated Android Studio from 2.x to 3.x last week end. The project migration was perfect, build was great. And now, from 2 hours, I can't explain why, I can't build, I have this error on Glide now:

Error:(26, 22) error: cannot find symbol class GlideApp

All was good before, I didn't change anything (gradle or configuration), and now this error appears...

For information about Glide, in my Gradle:

annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
compile 'com.github.bumptech.glide:okhttp3-integration:4.0.0-RC1'

The GlideApp file is generated automatically (I checked it).

So, it's a crazy situation. Thank you very much guys!

12 Answers

The same happened to me and it was one of weirdest errors I ever got, I used Butterknife in my project and I found out that if you define the views in private mode, you get this error

use:

@BindView(R.id.tv_option_one)
TextView tv_option_one;
@BindView(R.id.tv_option_two)
TextView tv_option_two;

instead of

@BindView(R.id.tv_option_one)
private TextView tv_option_one;
@BindView(R.id.tv_option_two)
private TextView tv_option_two;

it mostly happens when Butterknife can't find the view when you use bindView or the onClick annotation, and the worst part is that it shows errors everywhere except the place where they should be.

I ran into the same problem when I migrated to AndroidX. I ended up solving it by adding/updating the dependencies to

implementation 'com.github.bumptech.glide:glide:4.8.0-SNAPSHOT'
kapt 'com.github.bumptech.glide:compiler:4.8.0-SNAPSHOT'
kapt 'androidx.annotation:annotation:1.0.0-rc01'

Glide 4.x introduces some breaking changes. Be sure to follow the instructions in the Download & Setup page of Glide docs. Do not neglect the changes in proguard.cfg. After changes, rebuild your project and you should be able to access GlideApp.

add those dependencies like so

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

In my case, I forgot to apply kapt plugin, So I just added it to my module-level build.gradle.

apply plugin: 'kotlin-kapt'

You can find more details about it - Glide Docs

This also happens when you have another error in your code. Gradle doesn't get to generate Glide classes since another error is thrown before it

If you are using DI, you could try comment out GlideApp error code, then rebuild. IDE should you where the error truly is.

For me, the problem was that there was a different import error (which was a "valid" error, I had indeed deleted the referenced method).

But because I got like 20 messages that GlideApp can't be found when building the app, I didn't even notice that there was such an error.


After correcting that error and rebuilding the project, everything worked normally again.

Generation of the following class worked for me:

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


@GlideModule
public final class MyAppGlideModule extends AppGlideModule {
//   Dummy. Needed to generate GlideApp. See:
//   GlideApp.with(service). 
}
Related