【问题标题】:(LibGDX Android) Unable to instantiate activity ComponentInfo ClassNotFoundException(LibGDX And​​roid) 无法实例化活动 ComponentInfo ClassNotFoundException
【发布时间】:2016-09-01 18:48:03
【问题描述】:

我已经在 Eclipse 中导入了 gdx-setup 创建的项目。没有错误,但是当我尝试在手机或模拟器中启动应用程序时,应用程序崩溃并且我的 Logcat 中有这些消息: Logcat. 这是我的 android 类中的代码:

import android.os.Bundle;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.mygdx.game.MyGdxGame;

public class AndroidGame extends AndroidApplication {
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        initialize(new MyGdxGame(), config);
    }
}

Here is my android buildpath.

我知道这是一个常见问题,但我尝试了很多解决方案,但没有任何效果。 抱歉英语不好。

感谢您的帮助。

【问题讨论】:

    标签: java android eclipse libgdx classnotfoundexception


    【解决方案1】:

    由于 AndroidLauncher 中 Android 入门类的默认名称,我假设您将其重命名为 AndroidGame 以及代码中未更新的一些重要部分:

    /android/build.gradle:

    寻找这样的行: commandLine "$adb", 'shell', 'am', 'start', '-n', 'de.tomgrill.someandroidpackage.android/de.tomgrill.android.AndroidLauncher'

    /之前的部分必须与AndroidManifest.xml中的包名匹配

    就我而言:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="de.tomgrill.someandroidpackage.android"
    ......
    

    / 之后的部分必须匹配 AndroidLauncher 类,包括。包。

    这里:de.tomgrill.android.AndroidLauncher

    包:de.tomgrill.android

    班级:AndroidLauncher

    还要确保 AndroidManifest.xml 中活动的启动器类适合:

    <application
            ...... >
            <activity
                android:name="de.tomgrill.android.AndroidLauncher"
               .....>
                <intent-filter>
                    <...... />
                </intent-filter>
            </activity>
        </application>
    

    【讨论】:

      猜你喜欢
      • 2013-04-12
      • 1970-01-01
      • 2011-11-19
      • 2011-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多