Android的Eclipse中,将在的.jar" LIB"&安培;"新增建设路径和QUOT; VS放的.jar的"库" [英] Android, Eclipse, Put .jar in "lib"&"add to build path" vs Put .jar in "libs"

查看:259
本文介绍了Android的Eclipse中,将在的.jar" LIB"&安培;"新增建设路径和QUOT; VS放的.jar的"库"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图添加循环J的.jar库到我的项目,在Eclipse v3.7.2

首先,我添加了的.jar进入lib目录,右键点击它,拿起添加到构建路径。它编译罚款,但在执行我得到一个错误找不到类com.loopj.android.http.AsyncHttpClient。

所以我删除从构建路径中的.jar,并将其移动到库目录。

没有必要添加构建路径,当它在库目录,这一次,它编译罚款和执行也没关系。

那么,什么是lib目录和放大器之间的微妙差异; 添加到构建路径与库目录?

解决方案
  

那么,什么是lib目录和放大器之间的微妙差异; 添加到构建路径与库目录?

Android的电流生成工具(Eclipse和命令行)预计,罐子在库/ 目录。它将这些JAR文件自动添加到您的编译时的构建路径。更重要的是,它将把JAR文件中的内容到你的APK文件,因此他们将是你的运行时生成路径的一部分。

使用的lib / ,并与您的构建路径摆弄手动将解决编译时间问题,但你的JAR的内容是不是在你的APK,因此将无法使用要在运行时。

I was trying to add the loopj .jar library into my project, in Eclipse v3.7.2

First I added the .jar into the "lib" directory, right clicked on it and picked "add to build path". It compiles fine but when executing I get an error "Could not find class 'com.loopj.android.http.AsyncHttpClient'.

So I remove the .jar from the build path, and move it into the "libs" directory.

No need to add the the build path when it's in the "libs" directory, this time it compiles fine and executes fine too.

So what is the subtile difference between the "lib" directory & "add to build path" vs "libs" directory?

解决方案

So what is the subtile difference between the "lib" directory & "add to build path" vs "libs" directory?

Android's current build tools (Eclipse and command-line) expect that JARs are in a libs/ directory. It will automatically add those JARs to your compile-time build path. More importantly, it will put the contents of the JARs into your APK file, so they will be part of your run-time build path.

Using lib/ and mucking with your build path manually will solve the compile-time problem, but then your JAR contents are not in your APK and therefore will not be available to you at runtime.

这篇关于Android的Eclipse中,将在的.jar" LIB"&安培;"新增建设路径和QUOT; VS放的.jar的"库"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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