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

查看:30
本文介绍了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.

我正在为 Java IDE 使用 Eclipse.如果我将光标放在红色下划线的 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?

顺便说一句,我相信我使用的是 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-设置#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. 选择 Properties 并选择 Android 部分
  3. 确保选择了项目构建目标"之一.

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

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

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

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