应用程序不会在亚行上运行

时间:2016-04-06 15:48:24

标签: java android logging sdk adb

我一直在尝试创建一个Flappy Bird应用程序,它可以工作......至少,它可以在桌面上运行。我在Android上运行它遇到了很多麻烦。每当我尝试运行它时,它都不会在控制台中给出任何错误消息,但它会在Logcat中执行。此外,当我尝试运行它时,它总是强制关闭(在我的手机上)并说“不幸的是,Flappy Bird已经停止了”。我无法弄清楚为什么,因为我也是Android编程的新手,我无法正确读取Logcat来调试错误。我发布了一些与我所看到的相符的图像。

注意:我的设备是一个运行Android 4.3的root HTC,我已经完成了USB调试步骤。

Logcat after trying to run the app

我已经从SDK Manager安装了一些工具。我还安装了API的14,18和22(14之前的任何东西都不兼容)

Debug

这是在调试模式下运行后的样子。

如果您需要更多信息,我很乐意为您解答。

这是Logcat的文本版本

04-06 17:02:45.911: E/AndroidRuntime(10812): FATAL EXCEPTION: main
04-06 17:02:45.911: E/AndroidRuntime(10812): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mygdx.game/com.mygdx.game.AndroidLauncher}: java.lang.ClassNotFoundException: Didn't find class "com.mygdx.game.AndroidLauncher" on path: DexPathList[[zip file "/data/app/com.mygdx.game-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.mygdx.game-1, /system/lib]]
04-06 17:02:45.911: E/AndroidRuntime(10812):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at android.app.ActivityThread.access$600(ActivityThread.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at android.os.Handler.dispatchMessage(Handler.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at android.os.Looper.loop(Looper.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at android.app.ActivityThread.main(ActivityThread.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at java.lang.reflect.Method.invokeNative(Native Method)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at java.lang.reflect.Method.invoke(Method.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at dalvik.system.NativeStart.main(Native Method)
04-06 17:02:45.911: E/AndroidRuntime(10812): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mygdx.game.AndroidLauncher" on path: DexPathList[[zip file "/data/app/com.mygdx.game-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.mygdx.game-1, /system/lib]]
04-06 17:02:45.911: E/AndroidRuntime(10812):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at java.lang.ClassLoader.loadClass(ClassLoader.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at java.lang.ClassLoader.loadClass(ClassLoader.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    at android.app.Instrumentation.newActivity(Instrumentation.java)
04-06 17:02:45.911: E/AndroidRuntime(10812):    ... 12 more

从我在Logcat中看到的,AndroidLauncher中似乎出现了问题。这是由Libgdx自动创建的,所以我不太清楚这里的问题是什么。但它可能在initialize(new FlappyDemo(), config);

以下是完整的AndroidLauncher类供参考:

package com.mygdx.game;

import android.os.Bundle;

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

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

1 个答案:

答案 0 :(得分:0)

I ended up finding the answer myself. It was that I hadn't installed all the correct API's. All I had to was install API 23 (which also happened to be the targetSdkVersion). After that, it I restarted Eclipse and it worked.

SDK Manager after installing API 23