'Android Studio 3.x: error: cannot find symbol class GlideApp
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!
Solution 1:[1]
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'
Solution 2:[2]
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.
Solution 3:[3]
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.
Solution 4:[4]
add those dependencies like so
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
Solution 5:[5]
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
Solution 6:[6]
I have picked up this problem when a sub-package uses GlideApp with AppGlideModule being extended in a class one level up in the package hierarchy.
I suspect that the compiler tries to compile the sub-package classes before generating GlipeApp.
My solution was to extend AppGlideModule in a separate module and then add it as a dependency to all the modules using GlideApp.
Solution 7:[7]
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
Solution 8:[8]
If you are using DI, you could try comment out GlideApp error code, then rebuild. IDE should you where the error truly is.
Solution 9:[9]
I got the solution of this issue.
Build -> Clean project (After) Rebuild Project
Then after you will able to import the GlideApp in your project
For Reference https://github.com/bumptech/glide/issues/1945
Solution 10:[10]
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.
Solution 11:[11]
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).
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
