Glide: App got crashed when call Glide.get(context)

Created on 2 Jan 2018  路  5Comments  路  Source: bumptech/glide

Glide Version: 4.4.0 (the newest)

Integration libraries: 'com.zhy:okhttputils:2.6.2' 'com.squareup.okhttp3:okhttp:3.4.1' 3.3.1 3.4.2 3.8.1

Device/Android Version: MI 3 MIUI9.7.11.16

Issue details / Repro steps / Use case background: when first use Glide, app goto crash.


Glide load line / GlideModule (if any) / list Adapter code (if any):

Glide.with(mContext).load(url).into(image)


Layout XML:

<FrameLayout xmlns:android="...


Stack trace / LogCat:

Process: com.sunland.staffapp, PID: 4898
                                                                    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bumptech/glide/gifdecoder/GifDecoder$BitmapProvider;
                                                                        at com.bumptech.glide.Glide.<init>(Glide.java:326)
                                                                        at com.bumptech.glide.GlideBuilder.build(GlideBuilder.java:445)
                                                                        at com.bumptech.glide.Glide.initializeGlide(Glide.java:257)
                                                                        at com.bumptech.glide.Glide.initializeGlide(Glide.java:212)
                                                                        at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:176)
                                                                        at com.bumptech.glide.Glide.get(Glide.java:160)
                                                                        at com.bumptech.glide.Glide.getRetriever(Glide.java:612)
                                                                        at com.bumptech.glide.Glide.with(Glide.java:638)
(ZygoteInit.java:756)
                                                                     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bumptech.glide.gifdecoder.GifDecoder$BitmapProvider" on path: DexPathList[[zip file "/data/app/com.sunland.staffapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sunland.staffapp-1/lib/x86, /system/fake-libs, /data/app/com.sunland.staffapp-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
                                                                        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                        at com.bumptech.glide.Glide.<init>(Glide.java:326)聽
                                                                        at com.bumptech.glide.GlideBuilder.build(GlideBuilder.java:445)聽
                                                                        at com.bumptech.glide.Glide.initializeGlide(Glide.java:257)聽
                                                                        at com.bumptech.glide.Glide.initializeGlide(Glide.java:212)聽
                                                                        at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:176)聽
                                                                        at com.bumptech.glide.Glide.get(Glide.java:160)聽
                                                                        at com.bumptech.glide.Glide.getRetriever(Glide.java:612)聽
                                                                        at com.bumptech.glide.Glide.with(Glide.java:638)聽
(ZygoteInit.java:756)聽
question

Most helpful comment

i solved the problem, thanks to @sjudd

my solution:
i put glide in a library, when you import:

compile('com.github.bumptech.glide:glide:4.4.0@aar') {
transitive = true
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'

and you should update your compile version && v4 v7 version to 26 or higher, just like this:

compile 'com.android.support:support-v4:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compileSdkVersion 26

All 5 comments

I think your application is over 64k methods.
So, You can follow this tutorial : https://developer.android.com/studio/build/multidex.html

Regards,
Hieu Tran

@tvhieuit in fact, my app has already implements multidex.install()

This is some build error in your application, some of these may be helpful: https://github.com/bumptech/glide/issues?utf8=%E2%9C%93&q=+java.lang.ClassNotFoundException+.

In particular maybe #2633?

i solved the problem, thanks to @sjudd

my solution:
i put glide in a library, when you import:

compile('com.github.bumptech.glide:glide:4.4.0@aar') {
transitive = true
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'

and you should update your compile version && v4 v7 version to 26 or higher, just like this:

compile 'com.android.support:support-v4:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compileSdkVersion 26

This information is also now listed on the download/setup docs page here: http://bumptech.github.io/glide/doc/download-setup.html. Hopefully that's easier to find.

Was this page helpful?
0 / 5 - 0 ratings