简体   繁体   English

应用程序不会在 ADB 上运行

[英]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.我一直在尝试创建一个 Flappy Bird 应用程序,它可以工作……至少,它可以在桌面上使用。 I'm having a lot of trouble running it on Android.我在 Android 上运行它时遇到了很多麻烦。 Whenever I try running it, it doesn't give any error messages in the console, but it does in the Logcat.每当我尝试运行它时,它都不会在控制台中给出任何错误消息,但会在 Logcat 中给出。 Also, when I try to run it, it always force closes (on my phone) and says "Unfortunately, Flappy Bird has stopped."此外,当我尝试运行它时,它总是强制关闭(在我的手机上)并说“不幸的是,Flappy Bird 已经停止了”。 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.我不知道为什么,而且由于我也是 Android 编程的新手,我无法正确读取 Logcat 来调试错误。 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.注意:我的设备是运行 Android 4.3 的有根的 HTC,我已经完成了 USB 调试步骤。

尝试运行应用程序后的 Logcat

I have installed a few of the Tools from the SDK Manager.我已经从 SDK Manager 安装了一些工具。 I've also installed API's 14, 18 and 22 (anything before 14 was not compatible)我还安装了 API 的 14、18 和 22(14 之前的任何东西都不兼容)

调试

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这是 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.从我在 Logcat 中看到的情况来看,AndroidLauncher 中似乎有问题。 This was automatically created by Libgdx, so I'm not too sure what the problem could be here.这是由 Libgdx 自动创建的,所以我不太确定这里可能出现什么问题。 But it might be in the line initialize(new FlappyDemo(), config);但它可能在initialize(new FlappyDemo(), config);

Here is the full AndroidLauncher class for reference:这是完整的 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);
    }
}

I ended up finding the answer myself.我最终自己找到了答案。 It was that I hadn't installed all the correct API's.那是我没有安装所有正确的 API。 All I had to was install API 23 (which also happened to be the targetSdkVersion).我所要做的就是安装 API 23(它也恰好是 targetSdkVersion)。 After that, it I restarted Eclipse and it worked.之后,我重新启动了 Eclipse 并且它工作了。

安装 API 23 后的 SDK 管理器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM