本文介绍了当类清楚地存在时,我得到一个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.AndroidHttpI 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正在寻找jar在一个libs文件夹中,但是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!

推荐答案

作为一个快速修复,通过点击 Maven依赖关系 Java Build Path - Order and Export 窗口应该解决NoClassDefFoundError。

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

根据你附带的截图它看起来像您在Eclipse中以google建议的标准方式在Eclipse中设置(或导入)您的Android项目,但也可以使用Maven管理一些jar依赖关系。这不是建议,你应该使用纯粹的谷歌标准方式(libs /文件夹,因为r17)或完全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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 05:49