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!

+5


source to share


11 answers


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.



+8


source


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.

+5


source


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

.

+3


source


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

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'

      

+2


source


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.

+1


source


add these dependencies like

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

      

+1


source


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

0


source


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.

0


source


Use GlideApp for Kotlin instead of Glide

0


source


For me, there is an Error in another Activity, so the compiler did not complete compilation. I suggest: - make sure there are no errors - clear and build and - invalid cache and reload.

0


source


If you are using DI you can try commenting out GlideApp

errors GlideApp

and then rebuilding. The IDE owes you where the error really is.

0


source







All Articles