Error "Resource entry main is already defined" when adding a reference to gdx.jar

I’m trying to use Oxidizer to import a Java project that relies on libgdx, but when I add a reference to gdx.jar to the project, I get the following error:

Error    8    () res\layout\main.xml:0: error: Resource entry main is already defined.
res\layout\main.layout-xml:0: Originally defined here.
    C:\Program Files (x86)\MSBuild\RemObjects Software\Oxygene\RemObjects.Oxygene.Cooper.Android.targets    64    5    org.me.androidapplication9

To reproduce:
Create a new Android project
Add a reference to gdx.jar
Attempt to build.

Removing main.layout-xml from the project does not fix the error.

Im guessing an Andorid project doesn’ isn’t allowed to have a main() entrypoint function (because it’s a library that Android calls into, not a standalone executable per se)? But that’s just gut reaction from the error message, we’d have to investigate further, to be sure.

The original project I’m trying to convert was an Android project, so I assume that’s not the case. Thanks for looking at it, though. :slight_smile:

Mason

makes sense. can you send me.us the full project (attach here, or send to support@, if you don’t want it public)?

It’s an open-source project:

code.google.com/p/freegemas-libgdx/

Just trying to do some experimental poking around to see if it can be converted, to explore Android game programming in Oxygene.

but you said “import a Java project that relies on libgdx”. i’m assuming i need that project, and not just libgdx itself?

Freegemas is the project. The “libgdx” suffix just means that it uses GDX as the backend.

And really, to reproduce this bug you don’t even need that; all you need is a brand new Android project with a rreference to gdx.jar.

the link you provided as a " freegemas-1.0.jar", not a gdx.jar. is that the one? sorry tyo be dense, but i’m not familiar with this library

if so, i just downloaded it, added it to an empty (File|New Android app) app, and it builds, deploys and runs fine on my Nexus 7. What am i missing?

nevermind that, i found the real lib at http://libgdx.badlogicgames.com/releases/. added it to my project — still builds and installs fine. I used what looks to be the latest, libgdx-1.0.1.

So once again if you could send me a concrete and full project that shows what fails, that be great.

I’m sorry, I should have been more clear. The link I provided is a Google Code project; the code can be found under the Source tab and checked out with the provided SVN link. The gdx.jar file in question can be found under \trunk\freegemas-android\libs

Adding either of the two jar files in that folder to a new Android project results in the error described above.

[quote=“mh, post:9, topic:4272”]
nevermind that, i found the real lib at http://libgdx.badlogicgames.com/releases/. added it to my project — still builds and installs fine. I used what looks to be the latest, libgdx-1.0.1.[/quote]

That’s very strange. Can you try the one from the Google Code project?

I don’t have a full project, because I am literally being stopped cold at the very first step. I ran FreegemasActivity.java (a very short, simple file) through Oxidizer, found some unresolved references to stuff inside libgdx, added the reference to the project, and had it immediately fail to compile.

I attempted to narrow it down by various tests, until I found that adding gdx.jar to a brand new Android project will fail. It really is that simple. If you can’t reproduce that on your end, though… then things get aggravating. :frowning:

Well. you must have SOME project, if you get a build error. please zip up that project, as is, and send it to me.

https://dl.dropboxusercontent.com/u/104116583/org.me.androidapplication9.zip

This application too compiles and runs fine, for me (does nothing, just shows a black screen, but runs). You are referencing a different .jar file than i did, though — which just goes to show why details are (or could be) important, rather than vague steps such as "just use this library).

What version of Oxygene are you using, and can you try with the latest gamma?

—marc

Using Elements 7.1.73.1515. According to the download page, that’s the latest version. And as I said the JAR can be easily obtained from Google Code.

Where do I find the gamma builds?

Well, there’s 8 different jar files in the download and you’re not using gdx.jar, but a different one. In this case it made no diff, but it could have. My point is, i see a “this is so obvious you don’t need a test case to see it” bugreport at least once a week, and in 90% of the cases, that is not actually the case, and there’s more to it. As it stands, this cost 3 attempts to repro this on my end w/o result, because steps were vague.

pre-release builds can be found at http://beta.remobjects.com

All right, not sure what was going on with my project, but a brand new project with the layout XML removed works… sort of.

If I just use a brand new project with libgdx, it will load. But if I change the main activity’s parent class from Activity to com.badlogic.gdx.backends.android.AndroidApplication (found in gdx-backend-android.jar), it builds, but then immediately fails at runtime with java.lang.ExceptionInInitializerError.

A bit of Googling suggests that this is due to a NDK component in libgdx and it can be fixed by putting a couple .so files in my \libs folder… except this isn’t Eclipse. So how do I link .so files into the project?

Yeah. Just create a libs dir (doesn’t really matter what it’s called though) and set this:

(Native Libraries) to that dir.

1 Like

Thank you, Carlo! I’m able to actually run a simple libgdx program from Oxygene now!

1 Like

Does everyting work now?