使用 eclipse 将 jar 包含到 apk 中
我试图在我的 apk 文件中包含一个 jar 文件。
我尝试了以下方法:
- 将 jar 复制到我的项目中的
lib
目录 - 将 jar 添加到路径
- 启用 jar 导出
- 将 jar 复制到我的项目中的
- 只需将 jar 添加到我的项目路径(其他位置)
- 启用 jar 导出
但 apk 不包含该 jar。当我尝试启动应用程序时,控制台告诉我:
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
Please check logcat output for more details.
Launch canceled!
我正在使用
Eclipse IDE for Java Developers 版本:Indigo 服务版本 1 内部版本号:20110916-0149and
Android 开发工具 包 版本:16.0.1.v201112150204-238534
编辑: 这个问题就解决了。如果我没有在清单中根据需要声明该库,它就可以工作。 (奇怪的行为)
I am trying to include a jar file in my apk file.
I tried the following:
- copy the jar into
lib
directory in my project - add jar to path
- enable the jar for export
- copy the jar into
- simply add the jar to my project path (location anywhere else)
- enable jar for export
But the apk does not include the jar. When I try to lanch the application the console tells me:
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
Please check logcat output for more details.
Launch canceled!
I'm using
Eclipse IDE for Java Developers
Version: Indigo Service Release 1
Build id: 20110916-0149
and
Android Development Toolkit
Version: 16.0.1.v201112150204-238534
EDIT:
This problem is solved. If I don't declare the libary as needed in the manifest it works.
(Strange behaviour)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
确保您的
.JAR
是使用JavaSE-1.6 而不是 1.7
创建的Make sure your
.JAR
is created withJavaSE-1.6, not 1.7
不确定您是否已经解决了这个问题,但我遇到了类似的问题,当我尝试在模拟器上运行应用程序时,仅将“.jar”文件添加到库中并没有帮助。
最终让我取得进展的是经历同样的事情并添加如上所述的库,然后在“Java Build Path”对话框中,转到“Order and Export”选项卡,然后选择那里的 jar 文件, 也。然后 .apk 明显变大,应用程序完成了初始启动。 (后来它仍然死了,但我认为那里还有另一个权限问题。)
我希望这有帮助吗?
Not sure if you've resolved this, but I was having a similar problem and just adding the ".jar" file to the lib was not helping when I tried to run the app on the emulator.
What did finally allow me to make progress was to go through the same thing and add the library as described above, and then in the "Java Build Path" dialog, go to the "Order and Export" tab, and select the jar file there, too. Then the .apk was noticeably bigger, and the app got through the initial startup. (It still died afterward, but I think there is another permission problem there.)
I hope this helps?
也许你已经尝试过这个?:
右键单击项目-->属性 -
然后找到您的 JAR...你的项目中不需要它。
Maybe you have tried this?:
Right click Project --> Properties --
Then find your JAR...you don't need it in your project.
对我来说,以下方法有效:
检查它是否包含该行
在我的例子中,它丢失了,所以将其添加到文件中。
For me, the following worked:
.classpath
file in project folder.Check it contains the row
In my case, it was missing, so added it to the file.
右键单击项目-->属性--> Java 构建路径 -->添加外部 JAR。
并选择你想要添加什么的jar。单击确定..
Right click on project --> Properties --> Java BuildPath --> Add External JARs.
and select jar what do you want add. click Ok..
如果您尝试将 jar 文件添加到您的 Android 应用程序中
就像这样
创建 lib 文件夹并复制 .jar 文件
在 Eclipse 中,右键单击现有项目,然后选择属性。将出现一个弹出窗口。(右键单击“项目属性”)。
箭头 在其中,选择 Java 构建路径,然后单击“库”选项卡,这里单击“添加外部 Jar”按钮,然后浏览您的 jar 文件(在 lib 文件夹中)并选择“确定”。
if you are trying to add a jar file to your android application
simply it's like this
create lib folder and copy the .jar file
In Eclipse, right click on your existing project, then choose properties. There will be a pop up window.(Right Click on Project Properties).
Arrow In that, select Java Build Path and then click on Libraries Tab, Here click on Add External Jar's button and then browse your jar file(in the lib folder) and select ok.
1)在项目中创建一个lib文件夹并将jar文件复制到其中。
2) 现在在 Eclipse 中右键单击您的项目并选择属性
3) 属性--> java构建路径-->图书馆-->添加罐子。
4)在添加jars中,您可以找到您的jar文件
5)将jar文件一一添加
1) Create a lib folder in your project and copy the jar files in it.
2) Now in Eclipse right click your project and select properties
3) Properties--> java build path--> Libraries--> Add Jars.
4) In the add jars you can able to find out your jar files
5) Add the jar files one by one
在您的应用程序中创建一个文件夹并将 jar 文件粘贴到该文件夹中。
之后,转到 java 构建路径,然后从应用程序 jar 文件夹中选择 jar 文件,然后单击“确定”,我认为您的问题应该得到解决。
如果您有任何问题请告诉我。
create one folder in your application and paste jar file in that folder.
After that go to java build path then select jar file from your application jar folder and click ok, I think your problem should be resolve.
If you have any issue let me know.
也许它在新版本中发生了变化,但我必须做的是正常添加 jar 才能编译,然后确保我的 jar 文件也在 Java 构建路径设置的顺序和导出选项卡中选中。
Maybe it has changed in newer versions, but what I had to do was to add the jar as normal to be able to compile, then make sure that my jar file also is checked in the order and export tab of the Java Build Path settings.