在新版本的Glide 4.3中,我尝试使用它,但是无论我传递给它什么上下文,它都会崩溃。以下是显示给我的错误信息:
在Gradle中的lib文件夹中的代码
但是相同的错误仍然存在。
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);
and
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的类来解决警告问题。
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}
但是相同的错误仍然存在。
annotationProcessor
,请尝试将其添加到应用程序的build.gradle文件中,否则请查看此链接https://github.com/bumptech/glide/issues/2243。 - Navneet Krishna