Skip to content

Cannot resolve symbol 'GlideApp' #1939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sonzerolee opened this issue May 18, 2017 · 39 comments
Closed

Cannot resolve symbol 'GlideApp' #1939

sonzerolee opened this issue May 18, 2017 · 39 comments

Comments

@sonzerolee
Copy link

sonzerolee commented May 18, 2017

I'm trying to use glide 4.0.0-RC0 by Gradle:

dependencies {
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.caverock:androidsvg:1.2.2-beta-1'
    compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
    compile 'com.android.support:support-v4:25.3.1'
}

I followed the example here: https://github.com/bumptech/glide/tree/master/samples/svg/src/main/java/com/bumptech/glide/samples/svg
but after add glide by Gradle, I got error: Cannot resolve symbol 'GlideApp'
My source:

package com.example.quangson.glidesvg;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;

import android.content.ContentResolver;
import android.graphics.drawable.PictureDrawable;
import android.net.Uri;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.RequestBuilder;
import com.example.quangson.glidesvg.glide.SvgSoftwareLayerSetter;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "SVGActivity";

    private ImageView imageViewRes;
    private ImageView imageViewNet;
    private RequestBuilder<PictureDrawablerequestBuilder;
    LinearLayout ll;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imageViewNet = (ImageView) findViewById(R.id.svg_image_view2);

        requestBuilder = GlideApp.with(this)
                .as(PictureDrawable.class)
                .placeholder(R.drawable.image_loading)
                .error(R.drawable.image_error)
                .transition(withCrossFade())
                .listener(new SvgSoftwareLayerSetter());

        Uri uri = Uri.parse("http://www.clker.com/cliparts/u/Z/2/b/a/6/android-toy-h.svg");
        requestBuilder.load(uri).into(imageViewNet);
    }
}

Please help

@sonzerolee sonzerolee changed the title Cannot resolve symbol 'GlideApp' and 'GlideRequests' Cannot resolve symbol 'GlideApp' May 18, 2017
@sjudd
Copy link
Collaborator

sjudd commented May 18, 2017

You need to add the annotationProcessor dependency:

annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'

You also need to add an AppGlideModule. See the generated API documentation for details.

@bajicdusko
Copy link

@sjudd I've stumbled on this one as well, somehow with readme reading, @GlideModule part is skipped. Maybe it'd be useful to add it as part of the readme for v4. Just a suggestion :).

@rigo-ptz
Copy link

I have the same problem, but my code contains all necessary dependencies
compile "com.github.bumptech.glide:glide:4.0.0-RC1"
annotationProcessor "com.github.bumptech.glide:compiler:4.0.0-RC1"
compile "com.github.bumptech.glide:okhttp3-integration:4.0.0-RC1"
compile 'com.android.support:support-v4:25.3.1'
and

@GlideModule
public class MyGlideModule  extends AppGlideModule

Android Studio 2.3.3, Gradle 3.5.5, Android Gradle 2.3.3.

I've read other issues but didn't find anything helpful there.

@michaelhader
Copy link

michaelhader commented Jul 27, 2017

Hi,
i had the same problem and found out, that the plugin 'com.neenbedankt.android-apt' causes the problem.
When i removed this plugin and use annotationprocessor for all apt dependencies it works and GlideApp was generated.
Maybe it helps someone else too.

@xuehuashi
Copy link

@michaelhader i also do it,but it's still not generate glideapp

@zeroarst
Copy link

zeroarst commented Aug 16, 2017

In my case I am using Android Studio 3.0 beta2 in app build.gradle I have

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

I have to use kapt 'com.github.bumptech.glide:compiler:4.0.0' instead of annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'

If compiler does not work you should probably see an warning in the LogCat with Glide tag
Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored

@artemtkachenko
Copy link

same issue: Cannot resolve symbol 'GlideApp'

Added all dependencies and annotationProcessor and @GlideModule and it still does not work.

Seems this lib is not awesome anymore.

@KenLaam
Copy link

KenLaam commented Aug 31, 2017

Same issue here
I'm using Kotlin and update with kapt 'com.github.bumptech.glide:compiler:4.0.0'
and already add annotation @GlideModule but GlideApp was not generated

@KenLaam
Copy link

KenLaam commented Sep 1, 2017

Hi all,
I found solution for this case,
I'm using Android Studio 3.0 Canary version so I need to include apply plugin: 'kotlin-kapt' in app gradle
You can see more detail at here:
https://kotlinlang.org/docs/reference/kapt.html

@ljaniszewski
Copy link

@KENK11 The only solution that worked! Thanks mate.
And this -> http://bumptech.github.io/glide/doc/getting-started.html

is a joke.
You are making big change in a library that is used by half of android world and you can't even do a proper explaination.

Yeah, do a module class, and you're done. Bs. Where do I put this class? Can it be in some kotlin file alongside other classes? Does it need any contents or must be empty? What are the benefits of new system? What particular errors mean and how to solve them?

@TWiStErRob
Copy link
Collaborator

@ljaniszewski

... is a joke. You are making big change in a library that is used by half of android world and you can't even do a proper explaination.

don't need that tone... it is open source and most of the maintenance and support is done in free time. Feel free to contribute a better documentation: http://bumptech.github.io/glide/dev/contributing.html#documentation

Where do I put this class? Does it need any contents or must be empty?

Have you opened "See Glide’s generated API page for more information."? http://bumptech.github.io/glide/doc/generatedapi.html#kotlin

What are the benefits of new system?

http://bumptech.github.io/glide/doc/generatedapi.html#about
http://bumptech.github.io/glide/doc/migrating.html#generated-api

What particular errors mean and how to solve them?

I think GitHub issues already cover most of them. As far as I remember the resolution was always a missing step from these linked pages.

The only solution that worked!

I think your case is also similar, you missed a step at http://bumptech.github.io/glide/doc/generatedapi.html#kotlin where it links to https://kotlinlang.org/docs/reference/kapt.html

@KenLaam
Copy link

KenLaam commented Sep 3, 2017

@ljaniszewski

You are making big change in a library that is used by half of android world and you can't even do a proper explaination.

Lol I just share my solution and take a brief
Why you are too serious ?

@DCRichards
Copy link
Contributor

@KENK11 Thank you for pointing this out. I've now submitted with a PR to include this in the docs, looks like it'll be in v4.2.

@KenLaam
Copy link

KenLaam commented Sep 28, 2017

@DCRichards your welcome :)

@Redman1037
Copy link

Redman1037 commented Dec 1, 2017

Same issue with me , it worked fine with me in previous project , but in this project i am facing this issue

i am using all dependencies

compile 'com.github.bumptech.glide:glide:4.3.1'
compile 'com.github.bumptech.glide:annotations:4.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'

also included glide module

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

@GlideModule
public final class MyAppGlideModule extends AppGlideModule {

}

Tried clean,rebuild,make ,project, also did invalidate cache and restart but the issue still exists,
is there any thing else i can do ? As this issue is closed i am hoping there is some solution to it .

I like the old glide where we added only 1 dependency and worked perfectly fine.

@Redman1037
Copy link

Ok found out the cause after an hour of struggle . There was another issue in my project so my project was unable to build successfully , so GlideApp was not built hence showing this error . All the errors at the starting were of GlideApp and main error was hiding somewhere in the middle .

So guys if you did every thing i mentioned above and still getting this error the please check if there is some other issue in the project which is stopping build.

@DCRichards
Copy link
Contributor

@Redman1037 I've noticed that Android Studio 3.x is quite selective with its error output, I'd recommend using the command line and inspecting the more verbose output. it's saved me on numerous occasions.

@xuie0000
Copy link

我遇到一类这问题,其实是后面出现的错误引起的这个提示,仅仅是显示在前面,以为是GlideApp的错误,其实是后面的错误

@LloydBlv
Copy link

for anyone who is still facing this issue:
in my case I had the

implementation 'com.github.bumptech.glide:glide:4.4.0'
in my library module's build.gradle and the

kapt 'com.github.bumptech.glide:compiler:4.4.0'

inside my application module's build.gradle and the GlideApp class was not generated.

I ended up with having both dependencies inside my application module's build.gradle file!

@wilburx9
Copy link

For those experiencing this issue, also make sure annotationProcessor 'com.github.bumptech.glide:compiler:4.X.X is added to module level build.gradle

@xiaoc024
Copy link

xiaoc024 commented Jan 2, 2018

Other dependencies use annotationProcessor like butterknife may casue this problem. So check out other annotations' correctness first may be help.
e.g. I used butterknife and used @BindView(R.id.xx) but haven't the View to be bind under this code. delete this annotation then clean and make project will be useful.

@akshaypunchh
Copy link

akshaypunchh commented Feb 6, 2018

Just Make a class in your project after this just to clean your project.

package com.akshay.utils;
 
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
 
@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}

@iamutkarshtiwari
Copy link

iamutkarshtiwari commented Apr 3, 2018

This is the only answer the solved my this issue for me - https://stackoverflow.com/a/46638213

This configuration worked for me -

  • In app module gradle -
    implementation "com.github.bumptech.glide:glide:${glide_version}"
    implementation "com.github.bumptech.glide:okhttp3-integration:${glide_version}"
    kapt "com.github.bumptech.glide:compiler:${glide_version}"
  • In app proguard -
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep class com.bumptech.glide.GeneratedAppGlideModuleImpl
  • My Custom Glide module class -
package com.github.iamutkarshtiwari.glidedemoapp;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.module.AppGlideModule;

import java.io.InputStream;

import okhttp3.OkHttpClient;

@GlideModule
public final class OkHttp3GlideModule extends AppGlideModule {

    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        super.applyOptions(context, builder);
    }

    @Override
    public void registerComponents(Context context, Glide glide, Registry registry) {
        OkHttpClient client = new OkHttpClient.Builder()
                .build();

        OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client);

        glide.getRegistry().replace(GlideUrl.class, InputStream.class, factory);
    }
}

Note-

  • Glide 4.0 need not have "GlideModule" declaration in AndroidMinifest.xml
  • You need to Make project in order to generate GlideApp class

@asozcan
Copy link

asozcan commented May 9, 2018

In my case, i had another problem unrelated with GlideApp but also a single fail on compile causing fail on GlideApp too. Anyway, glideapp fills all error list and for javac there is a limit for printed errors and it's 50 by default. In this case it was not possible to see what is real problem for me. This is the solution for me to catch real issue.

allprojects {
    repositories {
        jcenter()
    }

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xmaxerrs" << "1000"
        }
    }
}

With this config Android Studio can list till 1000 error and you can see real error at the end of list usually. It was my 376th error :) . Rest was fake GlideApp errors. Yes, i have 375 different class which imports GlideApp, haha.

@mkmckenna
Copy link

Tried just about everything on multiple different SO questions to solve this issue. GlideApp is still not generating. This entire approach just seems like bad design to me and the fact so many people are having a problem is worrying.

@almalikiy
Copy link

I tried to use Glide 4.80 and stuck for a few days, even after following download & setup page.
Clean project, make project didn't work.

finally, works after deleted build directory and rebuild.

@pratikbutani
Copy link
Contributor

Hello everyone,

Seems like great discussion going on. Don't worry. I have solution.

Follow the steps:

  • Add dependency as follow (I used latest version)
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
  • Create package (as I always used structured code) myglide and copy/paste following class:
@GlideModule
public class SampleGlideModule extends AppGlideModule {
    @Override
    public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
        super.applyOptions(context, builder);
    }
}
  • Now you can press CTRL+F9 OR you can click on Make Project option in Build menu. It will generate one file automatically (You can see by pressing CTRL and hover on ClassName in File.
final class GeneratedAppGlideModuleImpl extends GeneratedAppGlideModule {
  private final SampleGlideModule appGlideModule;
  ....
}

Now you can use GlideApp very easily. 💯

Hope it will helps you.

I love Glide as always. <3

@sadaharusong
Copy link

sadaharusong commented Dec 6, 2018

@pratikbutani

Hello everyone,

Seems like great discussion going on. Don't worry. I have solution.

Follow the steps:

  • Add dependency as follow (I used latest version)
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
  • Create package (as I always used structured code) myglide and copy/paste following class:
@GlideModule
public class SampleGlideModule extends AppGlideModule {
    @Override
    public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
        super.applyOptions(context, builder);
    }
}
  • Now you can press CTRL+F9 OR you can click on Make Project option in Build menu. It will generate one file automatically (You can see by pressing CTRL and hover on ClassName in File.
final class GeneratedAppGlideModuleImpl extends GeneratedAppGlideModule {
  private final SampleGlideModule appGlideModule;
  ....
}

Now you can use GlideApp very easily.

Hope it will helps you.

I love Glide as always. <3

Gradle sync failed: Could not resolve all dependencies for configuration ':MyProject:x86DebugRuntimeClasspath'.
Could not determine artifacts for com.github.bumptech.glide:glide:4.8.0
Could not get resource 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/4.8.0/glide-4.8.0.aar'.
Could not HEAD 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/4.8.0/glide-4.8.0.aar'.
Connect to d29vzk4ow07wi7.cloudfront.net:443 [d29vzk4ow07wi7.cloudfront.net/143.204.194.185, d29vzk4ow07wi7.cloudfront.net/143.204.194.28, d29vzk4ow07wi7.cloudfront.net/143.204.194.133, d29vzk4ow07wi7.cloudfront.net/143.204.194.97] failed: Read timed out
Read timed out
Consult IDE log for more details (Help | Show Log) (2 m 12 s 770 ms)

When I use your solution, andorid studio get this error log... have you even been have this error before?

@pratikbutani
Copy link
Contributor

@pratikbutani

Hello everyone,
Seems like great discussion going on. Don't worry. I have solution.
Follow the steps:

  • Add dependency as follow (I used latest version)
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
  • Create package (as I always used structured code) myglide and copy/paste following class:
@GlideModule
public class SampleGlideModule extends AppGlideModule {
    @Override
    public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
        super.applyOptions(context, builder);
    }
}
  • Now you can press CTRL+F9 OR you can click on Make Project option in Build menu. It will generate one file automatically (You can see by pressing CTRL and hover on ClassName in File.
final class GeneratedAppGlideModuleImpl extends GeneratedAppGlideModule {
  private final SampleGlideModule appGlideModule;
  ....
}

Now you can use GlideApp very easily.
Hope it will helps you.
I love Glide as always. <3

Gradle sync failed: Could not resolve all dependencies for configuration ':MyProject:x86DebugRuntimeClasspath'.
Could not determine artifacts for com.github.bumptech.glide:glide:4.8.0
Could not get resource 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/4.8.0/glide-4.8.0.aar'.
Could not HEAD 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/4.8.0/glide-4.8.0.aar'.
Connect to d29vzk4ow07wi7.cloudfront.net:443 [d29vzk4ow07wi7.cloudfront.net/143.204.194.185, d29vzk4ow07wi7.cloudfront.net/143.204.194.28, d29vzk4ow07wi7.cloudfront.net/143.204.194.133, d29vzk4ow07wi7.cloudfront.net/143.204.194.97] failed: Read timed out
Read timed out
Consult IDE log for more details (Help | Show Log) (2 m 12 s 770 ms)

When I use your solution, andorid studio get this error log... have you even been have this error before?

No, I never ever got this type of error. I am using latest version of Android Studio.

@Suaix
Copy link

Suaix commented Dec 25, 2018

Same question happened when i update android studio to v3.2.1, but GlideApp works fine in android studio v2.3.0 with same build config and same version of glide(glide v4.0.0).
Here is my build config and glideModule class:
dependencies { annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0' compile 'com.github.bumptech.glide:glide:4.0.0' }
`@GlideModule
public class UxinGlideModule extends AppGlideModule {

@Override
public void applyOptions(Context context, GlideBuilder builder) {
    super.applyOptions(context, builder);
    builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, 1024 * 1024 * 100))
            .setMemoryCache(new LruResourceCache(1024 * 1024 * 20))
            .setLogLevel(Log.ERROR);
}

@Override
public boolean isManifestParsingEnabled() {
    return false;
}

}`
Has anyone experience this question? How to fix it?

@pratikbutani
Copy link
Contributor

Have you tried this: press CTRL+F9 OR you can click on Make Project option in Build menu. It will generate one file automatically (You can see by pressing CTRL and hover on ClassName in File.

@Suaix
Copy link

Suaix commented Dec 27, 2018

I have tried Make Project and rebuild, it generate GlideApp in build/generated, but just can not found the symbol. Have no idea why cannot resolve the symbol, but it is useful after build apk.

@Redman1037
Copy link

Redman1037 commented Jan 11, 2019

Few more reasons Glide app wont be generated

  1. If you copy GlideModule from another project make sure package name is correct

  2. If you are using kapt 'com.github.bumptech.glide:compiler:4.8.0' then make sure you add apply plugin: 'kotlin-kapt' on top

@tilalapradip
Copy link

See here Kotlin guideline to Add Glide to Your App:
http://bumptech.github.io/glide/doc/generatedapi.html#kotlin
If you’re using Kotlin you can:
1. Implement all of Glide’s annotated classes (AppGlideModule, LibraryGlideModule, and GlideExtension) in Java as shown above.
2. Implement the annotated classes in Kotlin, but add a kapt dependency instead of an annotationProcessor dependency on Glide’s annotation processor:

@varunam
Copy link

varunam commented May 24, 2020

Ok found out the cause after an hour of struggle . There was another issue in my project so my project was unable to build successfully , so GlideApp was not built hence showing this error . All the errors at the starting were of GlideApp and main error was hiding somewhere in the middle .

So guys if you did every thing i mentioned above and still getting this error the please check if there is some other issue in the project which is stopping build.

True. I observed the same.

@ssjsaha
Copy link

ssjsaha commented Jul 3, 2020

Well In my case apply plugin: 'kotlin-kapt' caused the ERROR . .
So ,If you are usning it with only java, Removing kotlin-kapt plugin could solve your case . Thanks :)

@Mihir3646
Copy link

Mihir3646 commented Jul 31, 2020

There could be your project level error and just check at the bottom of the GlideApp error you will find the issue causing this. In my case, it was Parcelable POJO class which also extends RealmObject there was no public construction with no argument.

@jeffreyliu8
Copy link

my solution is simply using replace "implementation" with "kapt" in gradle on glideCompiler.

@pratikbutani
Copy link
Contributor

pratikbutani commented Apr 2, 2021

Must check this: https://stackoverflow.com/a/58267685/1318946

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests