【问题标题】:Programs run fine with LibGDX -desktop but not LibGDX - Android?程序运行良好 LibGDX -desktop 但不是 LibGDX - Android?
【发布时间】:2014-05-30 10:33:51
【问题描述】:

所以我刚刚设置了 Eclipse 以使用 Gradle 与 LibGDX 一起工作。安装后发现安卓包有问题,包旁边有个红叉。当我进一步打开它时,src 旁边有一个红十字,然后是 com.myname.game.android,然后是 AndroidLauncher.java。当我打开 AndroidLauncher.java 时,这是我得到的代码:

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

当我查看 AndroidLauncher.java 代码中的错误时,他们说:

-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   

我正在使用 SDK Manager 22.6.2 和最新的 Eclipse Gradle 插件。我有 JRE 8 和 JDK 7。有没有办法解决这个问题?提前致谢。

【问题讨论】:

标签: java android eclipse gradle libgdx


【解决方案1】:

默认没有选择Android版本,所以去: Project -> Properties -> Android -> Project Build Target 并选择您喜欢的版本

【讨论】:

  • 太棒了:它起作用了(现在我注意到日志中的错误:Unable to resolve target 'android-19' 这本来是一个提示)
【解决方案2】:

我不知道为什么这有效,但它对我有用。我安装了ADT插件,刷新了android部分,红叉消失了。

请参阅“下载 ADT 插件”一节以安装 ADT 插件。 http://developer.android.com/sdk/installing/installing-adt.html

之后,转到 Eclipse > Package Explorer > 左键单击 Project-android > 选择 Refresh。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-08
    • 2016-05-29
    • 2019-04-27
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 2013-07-27
    相关资源
    最近更新 更多