English 中文(简体)
日食时无法参考其他项目的Android项目
原标题:Android project unable to reference other project in eclipse

拥有一个名为“ 测试和机器人” 的机器人项目。 我能够在我和机器人设备上运行它。 但是我想使用另一个项目的代码。 所以我去我的建筑路径添加项目测试。 测试是使用 java6 的标准 java6 。 测试项目有一个类测试, 这只是一个空类。

这里它混乱了, 当我在测试和机器人中创建测试实例时, 我有一个运行时错误。 这是我从日志中获取的错误 。

05-27 21:47:49.976: E/dalvikvm(27493): Could not find class  com.tests.eclipseisbroken.Test , referenced from method com.tests.eclipseisbroken.TestAndrodiActivity.onCreate
05-27 21:47:49.986: W/dalvikvm(27493): VFY: unable to resolve new-instance 11 (Lcom/tests/eclipseisbroken/Test;) in Lcom/tests/eclipseisbroken/TestAndrodiActivity;
05-27 21:47:49.986: D/dalvikvm(27493): VFY: replacing opcode 0x22 at 0x0008
05-27 21:47:49.986: D/dalvikvm(27493): VFY: dead code 0x000a-000d in Lcom/tests/eclipseisbroken/TestAndrodiActivity;.onCreate (Landroid/os/Bundle;)V
05-27 21:47:50.026: D/AndroidRuntime(27493): Shutting down VM
05-27 21:47:50.046: W/dalvikvm(27493): threadid=1: thread exiting with uncaught exception (group=0x40028a00)
05-27 21:47:50.056: E/AndroidRuntime(27493): FATAL EXCEPTION: main
05-27 21:47:50.056: E/AndroidRuntime(27493): java.lang.NoClassDefFoundError: com.tests.eclipseisbroken.Test
05-27 21:47:50.056: E/AndroidRuntime(27493):    at com.tests.eclipseisbroken.TestAndrodiActivity.onCreate(TestAndrodiActivity.java:16)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1065)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at android.app.ActivityThread.access$2300(ActivityThread.java:135)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at android.os.Looper.loop(Looper.java:143)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at android.app.ActivityThread.main(ActivityThread.java:4914)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at java.lang.reflect.Method.invokeNative(Native Method)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at java.lang.reflect.Method.invoke(Method.java:521)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-27 21:47:50.056: E/AndroidRuntime(27493):    at dalvik.system.NativeStart.main(Native Method)

我认为我的日食安装一定有问题,因为我有一个项目, 是因为我不得不引用另一个项目,而且它起作用了。我宁愿现在把它完全重新安装了日食和我的插件。如果有人知道什么是错的并且可以帮助我的话,我会非常感激。 谢谢!

问题回答

假设您使用最新的Android SDK & amp; ADT 版本, 您想要添加一个标准 java 工程 < strong> > B , 作为该工程中的依赖性 。 < strong > A :

  1. Add project B to project A s build path: Properties -> Java Build Path -> Projects -> Add ...
  2. Tick project B in project A s build path export list: Properties -> Java Build Path -> Order and Export

现在您应该能够使用标准的 java 库中的类, 在您的 Android 工程中使用该类, 然后在 Eclipse 中创建/ 运行/ 调试它 。

希望这能帮上忙

更新: 以上操作仅在 < code>. glaspath 中添加一行

<classpathentry combineaccessrules="false" exported="true" kind="src" path="/projB"/>




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签