bugs in eclipse after installing LibGDX - java

i had no project in eclipse, and i just followed the steps in this toturial: https://www.youtube.com/watch?v=S9fs1PVTyUc&src_vid=6i78aqugqds&feature=iv&annotation_id=annotation_4141831685
and it opened for me a few projects named:
project,
project-android,
project-core,
project-desktop,
project-ios.
and the project-android had an error.
here is the code:
package com.ak01.projext.android;*
import android.os.Bundle;**
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.ak01.projext.Projec;
public class AndroidLauncher extends AndroidApplication {***
#Override
protected void onCreate (Bundle savedInstanceState) {****
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new
AndroidApplicationConfiguration();
initialize(new Project(), config);
}
}
but it has a few errors although i didn't touch it yet(the number of *'s matches to the line)
*The type android.os.Handler cannot be resolved. It is indirectly referenced from required .class files
**The import android.os.Bundle cannot be resolved
***Multiple markers at this line
-The type android.app.Activity cannot be resolved. It is indirectly referenced from
required .class files
-The hierarchy of the type AndroidLauncher is inconsistent
****Bundle cannot be resolved to a type

It looks like you have not installed the Android developer tools.
To test this, right click your project and press build path. On the side there should be an 'Android' tab, if there isn't you need the android plugin for eclipse.

You can try to use the advanced option to check eclipse as #Tuss said in a comment. Also note that you need the version 19 of Android SDK (it isn't valid the last version at the time of writing this, API 23).
When creating the Libgdx project:
In Libgdx Project Generator open Advanced options.
Check Eclipse.
Generate your project.
In Eclipse:
Open Android SDK Manager: Window -> Android SDK Manager.
Mark if it isn't installed the SDK Plataform for Android 4.4.2 (API 19) and install it.
Finally import the projects with File -> Import -> General -> Existing Projects into Workspace.

Related

Gradle dependency vs. java import statement in Android studio

I'm trying to pull together an Android project, it includes several library packages, and a demo app that utilize the libraries.
I'm using Android Studio and Gradle. (I used to work with Eclipse, without gradle.)
So here in Android Studio, I have a project including several packages(or modules? what's the difference in concept?)
I have a core library project. And another library, say Flavor, that utilizes core.
In the Flavor module,
In build.gradle file, I have
dependencies {
....
compile project(':**core-project**')
....
}
I understand it as that Gradle add the core project build path to my Flavor project. (Same way that you can do it manually in Eclipse. See picture)
In java file,
import org.project.**core**; //this shows Unused
public MyFlavorClass extends CoreClass {
...
}
I deleted the import statement and it seems fine.
So why the import statement is not needed here?

I am getting an error in libGDX program only for the Android Build

I successfully imported a libGDX Gradle build in Eclipse Mars. Then, I see a red cross on the Android Build. When I open the Android.java file, it gives a bunch of errors on different things.
The errors look like this:
The type android.os.Handler cannot be resolved. It is indirectly referenced from required .class files for package com.arch.project.android;
The import android.os.Bundle cannot be resolved for import android.os.Bundle
The hierarchy of the type AndroidLauncher is inconsistent for public class Android Launcher
The type android.app.Activity cannot be resolved. It is indirectly referenced from required .class files for public class Android Launcher extends AndroidApplication.
Bundle cannot be resolved to a type for protected void onCreate (Bundle savedInstanceState) {
See the picture for more details!
Screenshot of android build of libgdx

Programs run fine with LibGDX -desktop but not LibGDX - Android?

So I have just set up Eclipse to work with LibGDX using Gradle. After I installed I noticed there was a problem with the Android package, there was a red cross next to the package. When I opened it further there was a red cross next to src then com.myname.game.android and then in AndroidLauncher.java. When I opened the AndroidLauncher.java, this was the code I got:
package com.faturbansloth.game.android;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.faturbansloth.game.MyGame;
public class AndroidLauncher extends AndroidApplication {
#Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new MyGame(), config);
}
}
When I looked at the errors in he code of AndroidLauncher.java they were saying:
-The type android.os.Handler cannot be resolved. It is indirectly referenced from
required .class files
-The import android.os.Bundle cannot be resolved
-Multiple markers at this line
- The type android.app.Activity cannot be resolved. It is indirectly referenced from
required .class files
- The hierarchy of the type AndroidLauncher is inconsistent
-Bundle cannot be resolved to a type
I am using SDK Manager 22.6.2 with the newest Gradle plugin for Eclipse. I have JRE 8 and JDK 7. Is there anyway to fix this problem? Thanks in advance.
There was no Android Version selected by default, so go:
Project -> Properties -> Android -> Project Build Target and select your preferred version
I have no idea why this works but it does for me. I installed the ADT plugin, refreshed the android section and the red cross disappeared.
Refer to the section under "Download the ADT Plugin" to install the ADT plugin.
http://developer.android.com/sdk/installing/installing-adt.html
After that, go to Eclipse > Package Explorer > Left click on Project-android > Select Refresh.

Imported Eclipse projects not compiling

I installed Eclipse 4.2 in new windows 8, and copied and imported all my projects. All projects are based on phonegap so have the phonegap build
None will compile and all have red X by the src> app.java although they work fine in the original eclipse.
I dont understand the errors so dont know where to start:
My Code: The error for the line in () not part of code
package com.x.x;
import android.os.Bundle; (ERROR=The import android.os.Bundle cannot be resolved)
import com.phonegap.*;
public class App extends DroidGap { (ERROR= The hierarchy of the type App is inconsistent)
/** Called when the activity is first created. */
#Override (ERROR = Override cannot be resolved to a type)
public void onCreate(Bundle savedInstanceState) { (ERROR=Bundle cannot be resolved to a type)
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html"); (ERROR = The method loadUrl(String) from the type DroidGap refers to the missing type String)
}
}
Error line 1:
Multiple markers at this line
- The type android.os.Bundle cannot be resolved. It is indirectly referenced from
required .class files
- The type android.content.Intent cannot be resolved. It is indirectly referenced from
required .class files
- The type java.lang.String cannot be resolved. It is indirectly referenced from
required .class files
- The type java.lang.Object cannot be resolved. It is indirectly referenced from
required .class files
Step one is to resolve your JRE setup, which is obviously not in order (java.lang.Object cannot be resolved). Open project properties, Java Build Path, Libraries, and in the list find the item referring to the JRE. Edit this entry. You will probably need to locate the JRE on your filesystem.
I resolved by following this steps..
open project properties, java build path, libraries, search for JRE, select that and remove JRE, click on add libraries, select JRE system libraries, click next and check both execution environment and alternative jre than click on finish. Now again open project than select clean. This will clean your project.
Just go to the compile setting and check project specific setting and then change the compiler version. This can be resolved from there.
I had the same errors on my project, but I fixed it in a different way, here's what I did:
Right clicked my android project (the root) and selected Properties
Clicked on 'Android' on the list towards the left
Ticked an Android Build from the Build Target list, like Android #.#.# (Android 4.0.3 for example)
Clicked okay and that was it! Cleared all my errors :)
Try this:
Right click on package > Build Path > Configure Build Path
Select Java Build Path > click on Classpath, remove the existing JRE libraries.
Add Library > JRE system library > Alternate JRE > Installed JRE > Add > Standard VM > Browse the jre folder and point JRE Home to that directory where you installed JRE > Finish.
This should fix the problem.

android.os.Bundle cannot be resolved in libgdx Android project

I've just started using Libgdx to practice making games and I used the project creation .jar provided on the site to create the initial projects. However an error shows up in the Android project which says:
android.os.Bundle cannot be resolved.
I am using Eclipse for Java IDE. If I put the cursor over AndroidApplication which is underlined in red, it suggests that I configure the build path. I believe I have the Android SDK installed, because it worked a while back on a different workspace on a simple example project. Does anyone know what I might have done wrong in this new workspace? How can I configure the build path for the AndroidApplication class?
BTW, I believe I'm using Java 1.6 as that's what JAVA_HOME points to, although I've also got Java 1.7 installed. That might not be relevant though...
package com.example.drop;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
public class MainActivity extends AndroidApplication {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useGL20 = false;
cfg.useAccelerometer = false;
cfg.useCompass = false;
initialize(new Drop(), cfg);
}
}
The error you are seeing is related to the Android SDK configuration, and is not specific to libGDX. The compiler does not know which Android libraries to compile against.
Use the LibGDX tutorials to setup your projects correctly. (See
https://github.com/libgdx/libgdx/wiki/Manual-project-setup#android-project-setup.
The first step in there does the Android-specific setup.)
If you do not want to create a new project but fix an existing project, the following steps should configure a project to build against Android:
right-click on the project in the Eclipse Package Explorer
select Properties and pick the Android section
Make sure exactly one of the "Project Build Targets" is selected.
That should add the required Android libraries to the build path as a side-effect.
Please, also check to have ADT installed on Eclipse.

Categories

Resources