如何使用和打包JAR文件与我的Android应用程序? [英] How to use and package a JAR file with my Android app?

查看:226
本文介绍了如何使用和打包JAR文件与我的Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JAR形式的API,我想在我的Android应用程序中使用。不确定它是否应该是Eclipse中的项目的一部分,或者保持分开并添加到项目属性中。这个JAR还需要与应用程序一起打包,那么这个Android应用程序是如何完成的?

I have an API in the form of a JAR that I would like to use in my Android app. Not sure if it should be part of the project in Eclipse or kept separate and added to the project properties. This JAR also needs to be packaged with the application, so how is that done for Android apps?

推荐答案

一个href =https://stackoverflow.com/questions/1334802/how-can-i-use-external-jars-in-an-android-project> SO问题:

As explained by this SO question:


  • 您的项目 - >右键单击 - >导入 - >存档文件 - > yourjar.jar

  • 您的项目 - >右键单击 - >属性 - > Java构建路径 - >库 - >添加Jar - > yourjar.jar

  • Your Project -> right click -> Import -> Archive File -> yourjar.jar
  • Your Project -> right click -> Properties -> Java Build Path -> Libraries -> Add Jar -> yourjar.jar

您必须将其添加为外部JAR文件,并在Eclipse项目中设置订单和导出。

You must add it as "external JAR" files, and set the "Order and Export" in your Eclipse project.

2012年2月更新:

Update February 2012:

Pacerier 在发表评论时提到了一个问题(ClassNotFound),尽管他已经宣布了图书馆。

他有:

Pacerier mentions in the comment having an issue (ClassNotFound) even though he did declare the library.
He had:

但是,解决方案很简单:

However, the solution was simple:

浪费了1个小时。男人是我生气了!

解决方案:确保你的JAR是用1.6编译,而不是1.7

Argh

Over 1 hour wasted. Man was I pissed!
Solution: make sure your JAR is compiled with 1.6 and not 1.7.
Argh

这篇关于如何使用和打包JAR文件与我的Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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