【问题标题】:AndroidHttp Exception NoClassDefFoundErrorAndroidHttp异常NoClassDefFoundError
【发布时间】:2012-05-07 18:27:54
【问题描述】:

我正在使用 eclipse 制作一个访问谷歌日历 API 的 android 应用程序 每当我尝试执行此方法时,都会收到 NoClassDefFoundError 异常

private void setupCalendarConnection(final String accessToken) throws IOException {

    HttpTransport transport = AndroidHttp.newCompatibleTransport();// Here where the exception 
    GoogleCredential googleCredential = new GoogleCredential().setAccessToken(accessToken);
    JacksonFactory jacksonFactory = new JacksonFactory();

我也尝试用

替换它

HttpTransport 传输 = 新的 NetHttpTransport () ;

我遇到了同样的错误

05-07 20:08:04.513: E/AndroidRuntime(781): java.lang.NoClassDefFoundError: com.google.api.client.extensions.android2.AndroidHttp

根据我对 Java 的了解。这个异常意味着我试图访问的类不是由 classLoader 定义的,尽管我检查了依赖项和 JAR 文件,并且它被包含和导入

所以关于我如何解决这个问题的任何线索 提前谢谢你..

Eclipse 3.7 Indigo --- Google-java-client-api 1.8----Android ICS(4.0.3) Api lvl 15

【问题讨论】:

    标签: java android noclassdeffounderror google-api-java-client


    【解决方案1】:

    通过 Project >> Properties 转到 Eclipse 中的构建路径,然后是 Java Build Path。在标签订购和导出下,勾选您要导入的库。

    【讨论】:

    • 感谢@Jason 的回复。我尝试了您的解决方案,但不幸的是我遇到了同样的错误
    • 我试过了,但出现另一个错误,阻止应用程序运行...(项目图标上的感叹号)
    【解决方案2】:

    当我使用 Netbeans 而不是 Eclipse 并在 libs 文件夹中手动导入我的 Jars 时,问题得到了解决...自动添加到 Project 并且它像火马一样运行。

    【讨论】:

      猜你喜欢
      • 2013-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多