Okhttp的NoClassDefFoundError [英] Okhttp NoClassDefFoundError

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

问题描述

我使用OkHttp 2.0.0罐子在我的日食Android应用程序。由于OkHttp现在依赖于奥基奥库,我还添加了奥基奥1.0.0罐子在我project.The项目编译罚款,没有编译错误,但是当我在我的Andr​​oid设备上运行,它给了我这样的的NoClassDefFoundError 所有与该OkHttp库类。

I am using OkHttp 2.0.0 jar in my android application on eclipse. As OkHttp is now dependent on Okio library, I also added Okio 1.0.0 jar in my project.The project compiles fine with no compilation errors but when I run on my android device, it gives me this NoClassDefFoundError all relating to the OkHttp library classes.

我已经把所有的罐子中的项目我的libs文件夹和将它们添加到我的构建路径,并试图在出口和顺序选项卡检查它们,但它仍然是行不通的。

I have placed all the jars in my libs folder of the project and added them to my build path and also tried checking them in the Export and Order Tab, but still it is not working.

我想知道,因为okhttp取决于奥基奥,只会增加双方的罐子会正常工作或我会做什么不同。

I wanted to know since okhttp is dependent on okio, will just adding both jars would work fine or would I have to do anything different.

我也曾尝试凌空罐子,它工作一切优秀无任何trouble.Anyone可以帮助我在这里,问题是围绕目前3〜4天。

I have also tried the volley jar and it works all fine without any trouble.Anyone could help me out here, the problem is around for now 3 to 4 days.

更新
我也试过了Android的工作室,并在构建依赖增加了okhttp库,但仍然没有工作。

Update I also tried the android studio and added the okhttp library in the build dependency but still not working.

推荐答案

在OkHttp 2.0.0语言层面进行了更新,Java 7中。

In OkHttp 2.0.0 the language level was updated to Java 7.

在这里看到更改日志 https://github.com/square/okhttp/ BLOB /主/ CHANGELOG.md

为了解决这个问题,你将需要更新到Java 7中。

In order to fix the issue you will need to update to java 7.

此外,在这一点上可能还需要改变目标SDK来奇巧(API 19),并更新你的构建工具等,以便为Android使用Java发挥好7

Also at this point you may also need change the target sdk to kitkat (API 19), and update your build tools etc in order for android to play nice with java 7

编辑:我有同样的问题,当我升级到2.0.0 okHttp和蚂蚁建造。虽然构建似乎接替我得到了NoClassDefFoundError的。通过我的构建日志会我有一大堆无声的错误

I had the same problem when i upgraded to okHttp 2.0.0 and built with ant. Although the build seemed to succeed i got the NoClassDefFoundError. Going through my build logs I had a whole bunch of silent errors

第一个来自javac的

The first came from javac

warning: com/squareup/okhttp/<classname>.class major version 51 is newer than 50, the highest major version supported by this compiler.

和DEX从第二个

[dx] trouble processing:
[dx] bad class file magic (cafebabe) or version (0033.0000)
[dx] ...while parsing com/squareup/okhttp/<classname>.class
[dx] ...while processing com/squareup/okhttp/<classname>.class

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

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