Android Glide库NoClassDefFoundError [英] Android Glide library NoClassDefFoundError

查看:138
本文介绍了Android Glide库NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我错误地使用了Glide库吗?可能是什么问题?

Am i using the Glide library wrongly? what could be the problem?

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ImageView iv = (ImageView) findViewById(R.id.imageView1);

    Glide.with(this).load(R.drawable.salads_caesar_salad).into(iv);
}

推荐答案

如果您的代码编译得很好,很可能您拥有对编译类路径的正确依赖。如果您使用Android Studio / Gradle,ProGuard可能会出于某种原因以某种方式剥离Glide类,但它实际上不应该因为您实际使用它。

If your code compiles fine it's highly likely you have the right dependencies on the compile classpath. If you use Android Studio/Gradle it's possible that ProGuard somehow strips the Glide class for whatever reason, but it really shouldn't because you're actually using it.

上面的矛盾和你的LogCat截图是Eclipse ADT或Android设备监视器( monitor.bat )的一个选项留下了一个选项:你没有导出您的依赖关系 ;尝试以下方法(请参阅链接手册中的屏幕截图):

The above contradicition and the fact that your LogCat screenshot is either that of Eclipse ADT or Android Device Monitor (monitor.bat) leaves one option: you didn't export your dependency; try the following (see the screenshot in the linked manual):


  1. 右键单击Android应用程序项目

  2. 属性

  3. Java构建路径

  4. 订单和导出

  5. 确保 glide.jar 已勾选

  1. Right click the Android Application Project
  2. Properties
  3. Java Build Path
  4. Order and Export
  5. make sure glide.jar is ticked

或者考虑在Android Studio(适用于Android开发的官方Google产品)或IntelliJ IDEA 14+中重新创建项目并复制源代码; IntelliJ Android插件比Eclipse ADT更好地支持Android和现代构建工具。我自己真的反对过渡,但是你看到它有效,因为现在我在倡导它。从长远来看,这值得花一两天时间。

Alternatively consider re-creating your project in Android Studio (official Google product for Android development) or IntelliJ IDEA 14+ and copying your sources over; the IntelliJ Android Plugin has much better support for Android and modern build tools than Eclipse ADT. I was really against the transition myself, but as you see it worked, because now I'm advocating for it. It's worth a day or two effort in the long run.

这篇关于Android Glide库NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆