无法访问 android.support 的片段类文件。v4.fragment 未找到

Cannot access fragmentclass file for android.support.v4.fragment not found

我正尝试在 android 工作室中执行此操作:

Glide.with(getApplicationContext()).load(Uri.parse(url.get((int)(5)))).into(imageview6);

但是显示如下错误

error: cannot access Fragment Glide.with(getApplicationContext()).load(Uri.parse(url.get((int)(5)))).into(imageview6);

Cannot access fragmentclass file for android.support.v4.fragment not found

我已尝试迁移到 AndroidX,但它只是说“未找到任何用法”。

使用getActivity()获取Fragmentclass中的上下文。

使用getActivity()代替getApplicationContext()

最终代码将是

Glide.with(getActivity()).load(Uri.parse(url.get((int)(5)))).into(imageview6);

希望这会奏效。

我使用了旧的 glide 依赖项,这就是我收到此错误的原因。尝试使用新更新的依赖项。这对我有用!