我怎样才能在Android项目使用外部JAR文件?文件、项目、Android、JAR

2023-09-11 10:21:04 作者:把你的爱扔进海里

我已经创建了一个Android项目,并增加了外部JAR(粗麻布-4.0.1.jar)到我的项目。然后,我将JAR添加到构建路径,并为了和出口检查它关闭。

I have created an Android project and added an external JAR (hessian-4.0.1.jar) to my project. I then add the JAR to the buildpath and check it off in Order and Export.

订单和出口被忽略,似乎,并且从外部JAR中的所有类都缺少运行。

Order and Export is ignored it seems, and all classes from the external JAR are missing in runtime.

有一招从外部JAR建筑使用Eclipse插件Android应用程序时正确包含所需的类。我并不想使用Ant或Maven。

Is there a trick to properly include the needed classes from an external JAR when building an Android application using the Eclipse Plug-In. I do not want to use ant or Maven.

推荐答案

外部JAR文件添加到您的Andr​​oid项目或Java项目的一个好方法是:

A good way to add external JARs to your Android project or any Java project is:

创建你的项目的根文件夹,名为 文件夹 您的 JAR文件复制到文件夹

现在右键点击Jar文件,然后选择构建路径>添加到构建 路径,这将创建一个文件夹,名为引用的库内的 项目 Create a folder called libs in your project's root folder Copy your JAR files to the libs folder

Now right click on the Jar file and then select Build Path > Add to Build Path, which will create a folder called 'Referenced Libraries' within your project

这样,你不会 失去了你的库正在上引用您 硬盘驱动器,只要你的项目转移到另一台计算机。

By doing this, you will not lose your libraries that are being referenced on your hard drive whenever you transfer your project to another computer.