Android,Eclipse,将 .jar 放入“lib"&“添加到构建路径"中vs 将 .jar 放入“libs"中 [英] Android, Eclipse, Put .jar in "lib"&"add to build path" vs Put .jar in "libs"

查看:30
本文介绍了Android,Eclipse,将 .jar 放入“lib"&“添加到构建路径"中vs 将 .jar 放入“libs"中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 Eclipse v3.7.2 中将 loopj .jar 库添加到我的项目中

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

首先,我将 .jar 添加到lib"目录中,右键单击它并选择添加到构建路径".它编译良好,但在执行时出现错误找不到类 'com.loopj.android.http.AsyncHttpClient'.

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'.

所以我从构建路径中删除了 .jar,并将其移动到libs"目录中.

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

在libs"目录下不需要添加构建路径,这次编译正常,执行也正常.

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

那么lib"目录和lib"目录之间的细微差别是什么?添加到构建路径"与libs"目录?

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

推荐答案

那么lib"目录和lib"目录之间的细微差别是什么?添加到构建路径"与libs"目录?

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

Android 当前的构建工具(Eclipse 和命令行)期望 JAR 位于 libs/ 目录中.它会自动将这些 JAR 添加到您的编译时构建路径中.更重要的是,它会将 JAR 的内容放入您的 APK 文件中,因此它们将成为您运行时构建路径的一部分.

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.

使用 lib/ 并手动修改您的构建路径将解决编译时问题,但是您的 JAR 内容不在您的 APK 中,因此您在运行时将无法使用.

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"&“添加到构建路径"中vs 将 .jar 放入“libs"中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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