欢迎使用CSDN-markdown编辑器

来源:互联网 发布:vps搭建虚拟专用网络 编辑:程序博客网 时间:2024/05/19 03:29

在eclipse中使用OKHttp和Butterknife的环境配置

大家在eclipse中使用现在比较流行的一些框架可能会遇到一些问题,下面我就将我使用Okhttp和Butterknife遇到的问题及解决方法描述一下:

Okhttp

eclipse中使用okhttp包时出现一下问题:
Dx bad class file magic(cafebabe) or version(0033.0000)这种问题。
原因是okhttp编译环境是jre1.7,而自己eclipse的编译环境比1.7低,所以造成这个问题。
解决方法如下:
直接右键项目,点击properties
这里写图片描述

点击Java Compiler选择JDK Compiler为1.7即可。
但是问题又来了,将JDK Compiler改为1.7后又提示Android build tools版本太低,于是又在sdk文件夹中找到build-tools文件夹,在其中添加了高版本的就OK了。

Butterknife

在Eclipse中使用Butterknife时,如果没对编译环境做特殊的配置,就会报空指针问题:
如下是我在stackoverflow上搜索的解决方案,在此就不翻译了,直接上图:
Right click on your project in the Package Explorer. Head to Java Compiler → Annotation Processing and check “Enable project specific settings”.
Ensure the other annotation processing settings are the same as shown below:
这里写图片描述

Expand the Annotation Processing section and select Factory Path. Check “Enable project specific settings” and then click “Add JARs…”. Navigate to the project’s libs/folder and select the Butter Knife jar.
这里写图片描述

Click “Ok” to save the new settings. Eclipse will ask you to rebuild your project to which you should click “Yes”
Make sure that the .apt_generated/ folder is in your project root. It should contain files like YOURACTIVITY$$ViewInjector.java. If these files are not present trigger a clean build by selected Project → Clean. This folder and files should not be checked into revision control.

以上就是在使用这个两个框架遇到的问题,在此记录一下。

0 0
原创粉丝点击