微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Libgdx,Android的传递依赖项,Java库项目,Jar

我刚刚创建了模板Libgdx项目(Core,Android,Windows).核心是常规的Java项目库. Core中对XStream.jar库有依赖性. Core包含通过Xml输入和输出文件. Android项目具有对Java核心项目的依赖.

现在,XStraem适用于Windows,但不适用于Android.对于Android,我得到了:

01-22 13:03:24.141: E/AndroidRuntime(25074): FATAL EXCEPTION: GLThread 5187
01-22 13:03:24.141: E/AndroidRuntime(25074): Process: com.barsoft.drag, PID: 25074
01-22 13:03:24.141: E/AndroidRuntime(25074): java.lang.NoClassDefFoundError: com.thoughtworks.xstream.XStream
01-22 13:03:24.141: E/AndroidRuntime(25074):    at com.barsoft.drag.managers.XmlManager.loadFromFileAutoType(XmlManager.java:29)
01-22 13:03:24.141: E/AndroidRuntime(25074):    at com.barsoft.drag.managers.ObjectManager.createObjectAutoType(ObjectManager.java:66)
01-22 13:03:24.141: E/AndroidRuntime(25074):    at com.barsoft.drag.Game.create(Game.java:36)
01-22 13:03:24.141: E/AndroidRuntime(25074):    at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:334)
01-22 13:03:24.141: E/AndroidRuntime(25074):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512)
01-22 13:03:24.141: E/AndroidRuntime(25074):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

如果我将库添加到Android项目的构建路径中,则会得到:

[2014-01-22 13:23:06 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/xmlpull/v1/XmlPullParser;
[2014-01-22 13:23:06 - drag-android] Conversion to Dalvik format Failed: Unable to execute dex: Multiple dex files define Lorg/xmlpull/v1/XmlPullParser;

当我在Core中检查库时,同样的东西->订购和出口

来自LibGDX的有关创建核心项目的文档:

  1. Main project setup Create a new Java project in Eclipse: File -> New
    -> Project -> Java Project. Give it a name and click Finish.

  2. Go to the project folder on the file system and create a sub-folder named libs.
    Download the nightly zip and place gdx.jar and gdx-sources.jar in the
    libs folder.

  3. In Eclipse, right click the project -> Refresh. Right
    click again -> Properties -> Java Build Path -> Libraries -> Add JARs,
    select gdx.jar and click OK.

  4. Under the gdx.jar file, double click
    “Source attachment”, click Workspace, select the gdx-sources.jar and
    click OK.

  5. Click the Order and Export tab, check the gdx.jar and click
    OK.

Note: Step 5 makes gdx.jar a transitive dependency. That means that
projects that depend on the main project will also have gdx.jar on
their classpath. However, this doesn’t work for Android projects.

这是否意味着Java核心项目中包含的任何依赖项在Android上均不起作用?
有没有办法让XStream传输库正常工作?

解决方法:

如果Android上支持该库,则它将起作用.

将其放在Core项目的“ libs”文件夹中.将其添加到其订单和导出标签.

将其添加到Android项目的“库”标签中. (“添加罐子”,而不是“添加外部罐子”),然后在“订单和以及导出选项卡.

That means that projects that depend on the main project will also have gdx.jar on their classpath. However, this doesn’t work for Android projects.

这只是意味着Core项目的类路径中的库不会自动添加到Android项目中(据我所知,前一段时间确实如此).

如果出现多个dex文件错误.取消选中“订购和订购”中的私人图书馆. Android项目的“导出”选项卡.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐