Android Studio 3.x: error: cannot find character class GlideApp
I upgraded Android Studio from 2.x to 3.x last week. The project migration was perfect, the build was great. And now, from 2 o'clock, I cannot explain why, I cannot build, I have this error on Glide now:
Error: (26, 22) error: Cannot find character class GlideApp
Everything was fine before, I didn't change anything (gradle or config) and now this error appears ...
For information about Glide in 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 this is a crazy situation. Thanks a lot guys!
source to share
Some of these situations appear from time to time (for an instance by a generated class R
where it is not instantiated ). The easiest way I've solved in the past is to clean the project and rebuild it. And if that doesn't work, click File
on the top menu and click "Invalidate caches and restart". A second pop-up window will appear, click "Invalidate caches and restart". This may take a while as Android Studio needs to re-index and rebuild the project, but it solves most of the problems I had.
source to share
The same thing happened to me and it was one of the strangest errors I have ever received, I was using Butterknife in my project and found that if you define views privately 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
@BindView(R.id.tv_option_one)
private TextView tv_option_one;
@BindView(R.id.tv_option_two)
private TextView tv_option_two;
this mostly happens when Butterknife cannot find the view when you are using bindView or onClick annotation, and worst of all, it shows errors everywhere except where they should be.
source to share
Glide 4.x introduces some violations. Be sure to follow the instructions on the Upload and Customize Glide Documents page . Do not neglect changes in proguard.cfg
. After the changes, rebuild your project and you should be able to access the GlideApp
.
source to share
I picked up this issue where the subpackage uses a GlideApp with the AppGlideModule extension at the first level in the package hierarchy.
I suspect the compiler is trying to compile the subpackage classes before generating the GlipeApp.
My solution was to extend AppGlideModule in a separate module and then add it as a dependency to all modules using GlideApp.
source to share
In my case, I forgot to apply the kapt plugin, so I just added it to my module at the level build.gradle
.
apply plugin: 'kotlin-kapt'
You can find more details on this - Glide Docs
source to share
Add dependencies to build.gradle (app)
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
Use Glide instead of GlideApp in your code
Glide.with(context).load("http://image_url").into(imageView);
Make sure you have Internet access permission in Manifest.xml if you are accessing a URL.
source to share