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:
Properties
and pick the Android
sectionThat should add the required Android libraries to the build path as a side-effect.
Please, also check to have ADT installed on Eclipse.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With