当类明显存在时,我收到 java.lang.NoClassDefFoundError [英] I am getting a java.lang.NoClassDefFoundError when the class is clearly there

查看:23
本文介绍了当类明显存在时,我收到 java.lang.NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在运行时尝试使用库时出现以下错误:java.lang.NoClassDefFoundError: com.google.api.client.extensions.android2.AndroidHttp我已将此库添加到我的项目中,它是 Maven 依赖项的第一个 jar(尽管我不是 100% 使用 Maven).

I am getting the following error when I am trying to use the library during runtime: java.lang.NoClassDefFoundError: com.google.api.client.extensions.android2.AndroidHttp I have added this library to my project, it is the first jar of the Maven dependencies( I am not 100% used to Maven though).

另外,我的理解是 Ant 正在寻找 libs 文件夹中的 jars,但 Maven 正在使用它自己的文件夹,这对其他项目工作正常.所以我迷路了..任何关于我应该如何解决这个问题的线索/帮助将不胜感激!

Also,My understanding is that Ant is looking for the jars in a libs folder, but Maven is using its own folder, and that works fine for an other project. So I am lost..any clues/help on how should I troubleshoot this would be much appreciated!

推荐答案

作为快速修复,通过在 Java Build Path - Order and Export 窗口中勾选 Maven Dependencies 应该解决 NoClassDefFoundError.

As a quick fix, By ticking Maven Dependencies in Java Build Path - Order and Export window should solve NoClassDefFoundError.

根据您附加的屏幕截图,您似乎按照谷歌在开发指南中建议的标准方式在 Eclipse 中设置(或导入)您的 Android 项目,但也以某种方式使用 Maven 管理一些 jar 依赖项.不推荐这样做,您应该使用纯粹的 google 标准方式(自 r17 起的 libs/文件夹)或完全 mavenize 您的 android 项目以进行依赖管理.

According to the screenshot you attached, it looks like you setup (or import) your Android project in Eclipse by the standard way google suggest in dev guide, but also somehow use Maven manage some of jar dependencies. This is not recommended, you should use either purely google standard way (libs/ folder since r17) or completely mavenize your android project for Dependency management.

这篇关于当类明显存在时,我收到 java.lang.NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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