为什么我得到类的链接失败导入到罐子在Eclipse中的Andr​​oid项目? [英] Why do I get Link of class failed importing a jar into an Android project in Eclipse?

查看:465
本文介绍了为什么我得到类的链接失败导入到罐子在Eclipse中的Andr​​oid项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Eclipse中我写了一个包类为使用Android和测试他们在一个Android项目,保证测试code在第二包。然后我用命令行创建从我的项目的bin / classes目录下的所有casses一个jar文件(只是我的库包,而不是测试包).Running罐子TF显示所有正确prefixed与类我的包的名称。

In Eclipse I wrote a package of classes for use with Android and tested them in an android project, keeping the test code in a second package. Then I used the command line to create a jar file from all the casses in my project's bin/classes directory (just for my library package, not the test package).Running "jar tf" shows all the classes correctly prefixed with my package name.

然后,我创建了原装进口我的第一个包活动的另一个Android项目和使用的方法,像这样:

I then created another Android project with an activity that imported my first package and used the methods, like this:

import uk.me.stevewaring.nestedsettings.NestedSettingsCommon;
import uk.me.stevewaring.nestedsettings.NestedSettingsReformat;
public class ShowNestedSettings extends Activity implements NestedSettingsReformat
{...

我然后右键点击我的新项目,并用于构建路径添加我的罐子。我的罐子显示了在图书馆Java构建路径的顶部,并在底部下订单和出口。

I then right clicked on my new project and used Build Path to add my jar. My jar shows at the top of the java build path under Libraries, and at the bottom under Order and Export.

在我加入我的罐子,从皮棉抱怨在我的包的方法,所有的红色波浪线消失了。

Once I added my jar, all the red squiggly lines from lint complaining about the methods in my package vanished.

然而,当我尝试调试我的项目,在 LogCat中我得到:

However when I try to debug my project, in the LogCat I get:

04-27 05:45:44.180: I/dalvikvm(14576): Failed resolving Lcom/example/shownestedsettings/ShowNestedSettings; interface 553 'Luk/me/stevewaring/nestedsettings/NestedSettingsReformat;'    
04-27 05:45:44.210: W/dalvikvm(14576): Link of class 'Lcom/example/shownestedsettings/ShowNestedSettings;' failed

然后运行失败,因为运行的类不存在。

and then the run fails because the class to run does not exist.

当我建立了原来的项目,我没有勾选框标记这个项目作为一个库,可能是这样的问题是什么?我不知道是什么效果复选框了。如果是这样的问题,有没有什么办法可以追溯力的行动,否则我将不得不建立一个完整的新项目,并复制我的包到它使用它来创建一个罐子之前。如果这不是问题,那么我做了什么错?

When I built the original project, I did not tick the box "Mark this project as a library", could that be what the problem is? I'm not sure what effect that check box has. If that is the problem, is there any way to retrospectively apply that action, or would I have to create a complete new project and copy my package into it before using it to create a jar. If that is not the problem, then what have I done wrong?

更多信息: 我删除了接口,的实现,那么,当我试图调试,我收到这样的:

Further information: I removed the implementation of the interface, then when I tried to debug, I received this:

04-27 05:52:10.919: I/dalvikvm(14677): Could not find method uk.me.stevewaring.nestedsettings.NestedSettingsCommon.initialise, referenced from method com.example.shownestedsettings.ShowNestedSettings.onCreate
04-27 05:52:10.949: W/dalvikvm(14677): VFY: unable to resolve static method 3566: Luk/me/stevewaring/nestedsettings/NestedSettingsCommon;.initialise (Landroid/app/Activity;)V
04-27 05:52:10.949: D/dalvikvm(14677): VFY: replacing opcode 0x71 at 0x0003

这并没有让我感到吃惊,NestedSettingsCommon.initialise是第一个打电话给我的活动作出code在我的罐子。

which did not surprise me, NestedSettingsCommon.initialise was the first call my activity made to code in my Jar.

我也试着从Eclipse导出命令行使它的罐来代替。这使得无论是没有什么区别。

I also tried exporting the Jar from in Eclipse instead of making it from the command line. That made no difference either.

推荐答案

请确保该JAR设置与应用程序中导出的:

Make sure the JAR is set to be exported with the application:

项目>属性> Java构建路径>订单和出口

这篇关于为什么我得到类的链接失败导入到罐子在Eclipse中的Andr​​oid项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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