Search code examples
javaandroidloggingsdkadb

App won't run on ADB


I've been trying to create a Flappy Bird app, and it works... at least, it does on desktop. I'm having a lot of trouble running it on Android. Whenever I try running it, it doesn't give any error messages in the console, but it does in the Logcat. Also, when I try to run it, it always force closes (on my phone) and says "Unfortunately, Flappy Bird has stopped." I can't figure out why, and since I'm also new to Android programming, I can't read the Logcat properly to debug the error. I've posted some images to go with what I've been seeing.

NOTE: My device is a rooted HTC that runs Android 4.3 and I have already done the USB debugging steps.

Logcat after trying to run the app

I have installed a few of the Tools from the SDK Manager. I've also installed API's 14, 18 and 22 (anything before 14 was not compatible)

Debug

This is what it looks like after running it in debug mode.

If you need anymore info, I'll be glad to get that to you.

Here is a text version of the 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

From what I've seen in the Logcat, there appears to be something wrong in the AndroidLauncher. This was automatically created by Libgdx, so I'm not too sure what the problem could be here. But it might be in the line initialize(new FlappyDemo(), config);

Here is the full AndroidLauncher class for reference:

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

Solution

  • 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