English 中文(简体)
从一个和机器人项目参考到另一个日圆
原标题:Refering from one android project to another Eclipse

我已经尝试了两个小时了,我似乎没有让它工作。我想在另一个项目中为我的应用程序建立一个框架。我首先试图从另一个项目中找到一个类。代码在运行时编辑但失败了,在线上我从框架的某个类中从一个类中抽出一个对象。

05-24 18:04:01.645: E/dalvikvm(16927): Could not find class  frame.test.Hello , referenced from method moduleLogin.activity.Login.loginClick
05-24 18:04:01.645: W/dalvikvm(16927): VFY: unable to resolve new-instance 190 (Lframe/test/Hello;) in LmoduleLogin/activity/Login;
05-24 18:04:02.715: W/dalvikvm(16927): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at android.view.View$1.onClick(View.java:2154)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at android.view.View.performClick(View.java:2538)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at android.view.View$PerformClick.run(View.java:9152)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at android.os.Handler.handleCallback(Handler.java:587)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at android.os.Handler.dispatchMessage(Handler.java:92)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at android.os.Looper.loop(Looper.java:130)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at android.app.ActivityThread.main(ActivityThread.java:3691)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at java.lang.reflect.Method.invokeNative(Native Method)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at java.lang.reflect.Method.invoke(Method.java:507)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at dalvik.system.NativeStart.main(Native Method)
05-24 18:04:02.720: E/AndroidRuntime(16927): Caused by: java.lang.reflect.InvocationTargetException
05-24 18:04:02.720: E/AndroidRuntime(16927):    at java.lang.reflect.Method.invokeNative(Native Method)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at java.lang.reflect.Method.invoke(Method.java:507)
05-24 18:04:02.720: E/AndroidRuntime(16927):    at android.view.View$1.onClick(View.java:2149)
05-24 18:04:02.720: E/AndroidRuntime(16927):    ... 11 more
05-24 18:04:02.720: E/AndroidRuntime(16927): Caused by: java.lang.NoClassDefFoundError: frame.test.Hello
05-24 18:04:02.720: E/AndroidRuntime(16927):    at moduleLogin.activity.Login.loginClick(Login.java:49)
05-24 18:04:02.720: E/AndroidRuntime(16927):    ... 14 more

我知道这个问题上有很多,但我已经搜索了几个小时而没有找到任何解决该问题的文章。 大部分议题是如何引用另一个项目。 但是,既然我的代码正在编纂,就应该引用它吗?

这两个项目是否需要是Android项目?框架项目应该是一个图书馆吗?感谢您的帮助!

最佳回答

if the library project is an android project , you need to make it a library one by choosing it from the project properties , and then to reference it via the same place but on the project that uses it. don t forget that there are some rules when you use a library project . see my post here for more information.

如果图书馆工程是java, 与使用其他java工程完全一样。

问题回答

这个机会很远,但对我来说很有效(在阅读了所有你所写的文章之后,

如果您确信您正确配置了工程参考文件, 这可能是无声构建失败的结果 。

就我而言,问题之所以出现,是因为我的两个项目的建筑环境不兼容。在纯爪哇的“A”项目中,在项目A的建筑环境中无误地编译了以下一行:

if ((int) d.get("good")) == 0) {....

事实证明,在(Android)“B”项目中,这不合法,该项目要求抛射物体:

if ((Integer) d.get("good")) == 0) {....

然而,我发现错误的唯一迹象 和你所经历的一样, 一个“VFY:无法解决...”错误。

我以痛苦的方式发现了错误:通过将“A”项目代码复制到“B”项目,找到错误,并在“A”项目中修正错误。也许有比我更聪明的方法可以找到这种不相容之处,比如对两个项目设置进行调整以精确匹配。





相关问题
In Eclipse, why doesn t "Show In" appear for non-Java files?

If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator. If I have an *xml, *jsp, or pretty much anything besides a Java source ...

Eclipse: Hover broken in debug perspective

Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable s value. Instead, hover behaves as if I were in normal Java perspective: alt text http://...

Eclipse smart quotes - like in Textmate

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I m a newbie here so be ...

Indentation guide for the eclipse editor

Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with ...

Adding jar from Eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the Add... button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to ...

How to copy multiple projects into single folder in eclipse

I have two projects, Project1 and Project2. Now i want to copy this projects into eclipse workspace but i want these projects to be in a single folder like below. Eclipse Workspace -> Project -> ...

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.

热门标签