如何在我的 Android 应用中使用和打包 JAR 文件?

2023-05-05Java开发问题
3

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

问题描述

限时送ChatGPT账号..

我有一个 JAR 形式的 API,我想在我的 Android 应用程序中使用它.不确定它是否应该成为 Eclipse 中项目的一部分,或者单独保存并添加到项目属性中.这个JAR也需要和应用一起打包,那么Android应用是怎么做的呢?

解决方案

如此解释 在评论中提到存在问题 (ClassNotFound),即使他确实声明了库.
他有:

但是,解决方案很简单:

浪费了1个多小时.伙计,我很生气!
解决方案:确保您的 JAR 是使用 1.6 而不是 1.7 编译的.

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?

解决方案

As explained by this SO question:

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

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


Update February 2012:

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

However, the solution was simple:

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

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

The End

相关推荐

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

如何在java中找出依赖于语言环境的文本方向?
How to find out locale-dependent text orientation in java?(如何在java中找出依赖于语言环境的文本方向?)...
2024-08-25 Java开发问题
24

如何控制 DateFormat 返回的月份和日期名称的大小写?
How to control the capitalization of month and day names returned by DateFormat?(如何控制 DateFormat 返回的月份和日期名称的大小写?)...
2024-08-25 Java开发问题
20

如何在 Java 应用程序中处理多种语言?
How to handle multiple languages in Java apps?(如何在 Java 应用程序中处理多种语言?)...
2024-08-25 Java开发问题
11

将 Java Swing 桌面应用程序国际化的最佳实践是什么?
What are the best practices for internationalizing a Java Swing desktop application?(将 Java Swing 桌面应用程序国际化的最佳实践是什么?)...
2024-08-25 Java开发问题
15

Eclipse 在尝试启动 Android 应用程序时卡住了
Eclipse gets stuck when trying to launch Android app(Eclipse 在尝试启动 Android 应用程序时卡住了)...
2024-08-25 Java开发问题
14