如何从命令行将外部 jar 库添加到 android 项目 [英] How to add external jar libraries to an android project from the command line

查看:27
本文介绍了如何从命令行将外部 jar 库添加到 android 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个具有一些依赖项的 Android 项目.jar 文件位于 lib/目录中.我可以通过将这些 jar 文件添加到我的类路径来构建项目,但当然它会在模拟器中强制关闭,因为这些库不存在.

I'm trying to build an Android project that has some dependencies. The jar files are in the lib/ directory. I can build the project by adding those jar file to my classpath, but of course it Force Closes in the emulator because those libraries aren't present.

我使用 ant 从命令行执行此操作(在 eclipse 中不是).如何从命令行将这些库包含在 apk 中?

I'm doing this from the command line with ant (not in eclipse). How can I make it include those libraries in the apk from the command line?

推荐答案

Jay K 的回答在撰写本文时是正确的,但现在 SDK 发生了变化,这里是新的方法:

Jay K's answer was right at the time of writing, but now the SDK has changed, and here is the new way to do it:

将以下行添加到 ant.properties:

jar.libs.dir=lib

经过测试,可以在 external.libs.dir 不起作用的情况下工作.
在 2010 年 12 月和 2011 年 10 月再次发生了变化.

Tested, works where external.libs.dir does not work.
That changed in December 2010 and then again in October 2011.

这篇关于如何从命令行将外部 jar 库添加到 android 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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