Glide crash 因为 context 4.3.1

Glide crash because of context 4.3.1

在新版本的 Glide 4.3 中,我尝试使用它,但无论何时使用它以及传递给它的任何上下文,它都会崩溃。

这是向我显示的错误

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

这是我试过的代码:

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

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

它给了我警告

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

和gradle中lib中的代码

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

更新1: 通过添加扩展 AppGlideModule

的 class 解决警告
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;

@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}

但同样的错误仍然存​​在

请在您的 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

检查:http://bumptech.github.io/glide/doc/configuration.html

对于像我一样来到这里并花了两天时间弄清楚 AppGlideModule 在哪里的人,我为那些人写了它,你必须在你的应用程序中创建一个 Class 并将其命名为 "MyAppGlideModule" 那么你应该把这段代码放在 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;
        }
    }

就是这样。