android.os.Bundle无法在libgdx Android项目中解决 [英] android.os.Bundle cannot be resolved in libgdx Android project

查看:1516
本文介绍了android.os.Bundle无法在libgdx Android项目中解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 Libgdx 练习游戏,并使用项目创建.jar提供该网站创建初始项目。但是,在Android项目中出现错误:

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无法解析。

android.os.Bundle cannot be resolved.

我正在使用Eclipse进行Java IDE。如果我将光标放在红色下划线的 AndroidApplication 中,则表明我配置了构建路径。我相信我已经安装了Android SDK,因为它在一个简单的示例项目的另一个工作区上工作了一会儿。有没有人知道我在这个新的工作区可能做错了什么?如何配置 AndroidApplication 类的构建路径?

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,我相信我使用的是Java 1.6就像JAVA_HOME指出的那样,虽然我也安装了Java 1.7。这可能不是相关的...

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);
    }
}


推荐答案

您所看到的错误与Android SDK配置相关,并不是特定于libGDX的。编译器不知道要编译哪个Android库。

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.

使用LibGDX教程正确设置项目。 (见
https://github.com/libgdx/libgdx/ wiki / manual-project-setup#android-project-setup
这里的第一步是Android特定的设置。)

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.)

如果您不想创建一个新的项目,但修复现有的项目,以下步骤应该配置一个项目,以建立与Android:

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:


  1. 右键单击Eclipse Package Explorer中的项目

  2. 选择属性并选择 Android section

  3. 确保选择了其中一个项目构建目标。

  1. right-click on the project in the Eclipse Package Explorer
  2. select Properties and pick the Android section
  3. Make sure exactly one of the "Project Build Targets" is selected.

应该将所需的Android库添加到构建路径中作为副作用。

That should add the required Android libraries to the build path as a side-effect.

这篇关于android.os.Bundle无法在libgdx Android项目中解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆