[SOLVED]libgdx and eclipse problem (newbie)

I’ve newly downloaded and am running the LibGDX project setup tool and it creates a new project just fine. Upon importing to Eclipse (Juno), I get this message in the console (several times):

[2013-07-31 19:07:51 - AngryMasons-android] Unable to resolve target 'android-15'

In the Problems, the first error (for the android project) is this:


The GWT SDK JAR gwt-servlet.jar is missing in the WEB-INF/lib directory	lib	/AngryMasons-html/war/WEB-INF	Unknown	Google Web Toolkit Problem

The second problem seems kind of bizarre also:

The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project	AngryMasons-android		Unknown	Java Problem

The AngryMasons-android project does not include “GWT SDK” library or the “JRE System Library[jre7]” or “App Engine SDK”. Should it? If I manually add these libraries, it does no good.

A “quick fix” on the gwt-servlet.jar error does put a copy into the -html/war/WEB-INF. But the other errors remain.

After the jre7 library is added, there is this:

The project was not built since its build path is incomplete. Cannot find the class file for android.app.Activity. Fix the build path then try building this project	AngryMasons-android		Unknown	Java Problem

And, on the code page that was generated, the very first import has an error:

The import android.os.Bundle cannot be resolved

Where is this library normally found?

I could go on listing errors but they are probably just cascades from the first errors, right?

Any help would be much appreciated. I’m quite stuck.

You’ve probably already seen this in the setup tutorial, but you need the Android SDK…
https://code.google.com/p/libgdx/wiki/ProjectSetup

Oh–Android doesn’t play well with Java 7? :cranky: I have to go back and reload Java 6? :cranky:

I was working with the “Prerequisites” link just above this tutorial, and then the tool “gdx-setup-ui.jar”. I didn’t think to look at the Manual Project Setup.

If Android doesn’t work with Java 7, why does the “Prerequisites” link for Java JDK point to…Java 7? ???

I may be kind of dense, but it kind of bugs me that the link to loading the Android SDK on an existing IDE points to a page that prominently displays a bundle that includes Eclipse, and the download for just the Android SDK is buried in the “Other platforms” area. I missed that twice.

I’m very tempted to just download the bundle and work with multiple Eclipse copies. Yay, another 200+ MB download!

(grousing aside, I do thank you, Jimmt for the link)
(and it is simply amazing that all this technology is free)

When I was using the project setup tool a few days ago I found that regardless of what I entered in the tool setup options, the generated project was always dependant on release 15 of the android sdk.

Assuming you’ve downloaded the latest one (which I think is 18) then it’s easiest to open the .project and Android-Manifest.xml files in the -android project and manually alter it.

Edit: When you do modify it, make sure to restart Eclipse, then do a full clean/rebuild.

I wonder: would using a Java 7 JDK but setting the compiler (in the workspace or project preferences) to Java 1.6 compliance work? The linked documentation states that you need to be using Java 1.6, but it does not state if you need to physically install a Java 6 JDK.

I’m struggling with this mightily because of everything being new.

The Android SDK Manager shows that I have Android 4.3 (API 18). The game-android project’s “AndroidManifest.xml” lists the “targetSdkVersion” as 17. I changed this to 18.

To ‘reload’ the project, I did the following:
(1) closed & reopened Eclipse (2) Project/clean, selecting the project files, (3) Refresh on the project itself.

Same errors.

About the JRE7–I loaded a separate tutorial/example from Google/Android that demos a “GreetingService”, and it is running fine, but the project is structured very differently. It has a copy of the jre7 library listed, so this makes me wonder if the presence of jre7 is really the problem. This tutorial project has the following libs and structures NOT in the game-android project generated by libgdx’s project setup tool:

App Engine SDK [App Engine - 1.8.2] (all the jars are listed as being in an Eclipse plugins folder)
GWT SDK [gwt-2.5.1 - 2.5.1] (all jars are listed from a download I had done of the toolkit and stored on my desktop/Java/gwt file folder)
JRE System Library [jre7]

And of course there are things like a war file folder, and WEB-INF, which I presume are not used for an Android program or the Android emulator.


I just tried manually adding the jre6 rather than the jre7 to the game-android project as a library. I don’t think it made any difference. The error about the class Object not being found goes away, but the other errors remain. The first problem listed is now (as before):
"Cannot find class file for android.app.Activity " etc. a build path issue.
Also, the class file MainActivity’s first error is on the import line:
“import android.os.Bundle;”

Any thoughts where one might find these?

I’ve download the “bundle” that includes a version of Eclipse with plugins already set up (presumably). Haven’t tried installing that yet and seeing if the game-android project works any better in that context. I also have yet to go through the manual install tutorial in detail. I guess I’ll do that next (after a search for “android.app.Activity” or “android.os.Bundle”).

Dang. Three days lost on my “schedule” due to this. Am wondering, maybe just delete the -android emulation and go forward with the rewrite of my game based on the -desktop and -html only. Worry about the -android version later? I kind of wanted to get the whole libgdx thing working first and finish Dustin Riley’s tutorials as a first step in getting acquainted with libgdx.

OK.

android.os.Bundle and android.app.Activity are part of the “android.jar” that was stored at a subfolder of the location listed by the Eclipse “SDK Path” listed in the Android SDK manager.

/android-sdk/platforms/android-18/android.jar

Why wouldn’t the setup automatically include a path to this jar? (The SDK path listed ends on “android-sdk”.) Did I configure something incorrectly?

I tried explicitly linking this as an “external jar” and all the errors in the MainActivity class go away. What I have now are a series of these errors:

Unable to resolve target ‘android-15’
Unable to resolve target ‘android-15’
Unable to resolve target ‘android-15’
Unable to resolve target ‘android-15’ until SDK is loaded.
Unable to resolve target ‘android-15’ until SDK is loaded.
Unable to resolve target ‘android-15’ until SDK is loaded.

Any ideas?

Yes, go to android project, rightclick, Properties -> Android and check your Android x.x.x Android 4.2.2 for example ;D Good luck coding!

Thank you!
All problems/errors are gone.

I’ve been working through the “manual” project start and was just noticed that Eclipse’s new project/Android project automatically adds the Android 4.3 library.

Clicking the properties/Android/Project Build Target: Android 4.3 seems to have accomplished the same thing with the project made via the libgdx project setup tool. Perhaps this could/should be added as another step in the libgdx project building tool, along with the instructions for correcting the “warnings” that come with some jars that need synchronizing?

This gets rid of the ridiculous error where java’s Object.class was not found. I can delete the manual addition of the jre6 as a library.

There are still a couple of differences. The “manually” created android project had “android-support-v4.jar” automatically included, and the libgdx setup tool android projects does not. There are a couple differences in terms of whether other jars are in the “Android Private Libraries” or “Referenced Libraries” in the two projects. But I’m guessing this doesn’t matter, and I’ll worry about the “android-support-v4.jar” presence later.

OK, on with the game tutorial! :slight_smile:

Ah, nice everything works now :wink:

I hope your tutorial isn’t starting with making menus as they are really complicated/confusing in LibGDX and I had a lot of trouble with making them as there are 1000 texture packers and only 1 properly works, (with 9patches), it was just very confusing for me, as this text is for you since you don’t know what texture packers/9patches are…

Now I know how it works, its great stuff, but all those youtube guys who teach beginners and start direct with making a menu for their game… Bad job… And the most terrifying thing is that they don’t even explain what they do… Bucky has to do a LibGDX tutorial, oO!

Nonetheless, LibGDX itself is great!