Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glide crash because of context 4.3.1

In the new version of the Glide 4.3 I'm trying to use it but it crash whenever I use it and whatever context I passed to it.

this is the error showed to me

   java.lang.AbstractMethodError: abstract method "void com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Glide, com.bumptech.glide.Registry)"

this is my code I tried:

Glide.with(getApplicationContext()).
            load(url)
            .into(imageView);

and

   Glide.with(getContext()).
            load(url)
            .into(imageView);

and it give me that warning

W/Glide: Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored

and the code in lib in gradle

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

Update1 : Waring Solved By Adding a class that extends AppGlideModule

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

@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}

but the same error still exist

like image 884
Sattar Avatar asked Nov 16 '17 10:11

Sattar


2 Answers

Please Add The Following Method on Your AppGlideModule class

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

To maintain backward compatibility with Glide v3’s GlideModules, Glide still parses AndroidManifest.xml files from both the application and any included libraries and will include any legacy GlideModules listed in the manifest. Although this functionality will be removed in a future version, we’ve retained the behavior for now to ease the transition. If you’ve already migrated to the Glide v4 AppGlideModule and LibraryGlideModule, you can disable manifest parsing entirely. Doing so can improve the initial startup time of Glide and avoid some potential problems with trying to parse metadata. To disable manifest parsing, override the isManifestParsingEnabled() method in your AppGlideModule implementation

Check : http://bumptech.github.io/glide/doc/configuration.html

like image 82
Mohammed Gamal Avatar answered Nov 15 '22 18:11

Mohammed Gamal


for people who came here like me and spent two days to figure out where is AppGlideModule or so, I write it for those people you must create a Class in your Application and Name it "MyAppGlideModule" then you should put this code in that class

package com.arash;


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

@GlideModule
    public final class MyAppGlideModule extends AppGlideModule {
        @Override
        public boolean isManifestParsingEnabled() {
            return false;
        }
    }

that's it.

like image 41
Arash Afsharpour Avatar answered Nov 15 '22 19:11

Arash Afsharpour