重新启动应用程序时,Android Emulator总是抛出异常(Android Emulator always throws Exception when relaunching applicati

编程入门 行业动态 更新时间:2024-10-10 12:24:27
重新启动应用程序时,Android Emulator总是抛出异常(Android Emulator always throws Exception when relaunching application)

我创建了一个简单的Android应用程序,它可以在Android Emulator上正常运行。 但是,当我修改某些内容(例如添加一个变量)并按下Run时,它会将apk文件发送到模拟器并显示“不幸的是MyApplication已停止工作”然后重新启动它并且它完美地工作。 我检查了日志,它与我的应用程序无关,它在APK加载器中抱怨一些NullException。 我重新启动了模拟器和Eclipse,我使用最新的SDK来构建我的应用程序,我的Min API级别是8,目标是16。 我不使用本机代码。 我在这里粘贴错误日志:

02-14 12:55:43.541: E/AndroidRuntime(723): FATAL EXCEPTION: main 02-14 12:55:43.541: E/AndroidRuntime(723): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.LoadedApk.makeApplication(LoadedApk.java:501) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4124) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.ActivityThread.access$1300(ActivityThread.java:130) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.os.Handler.dispatchMessage(Handler.java:99) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.os.Looper.loop(Looper.java:137) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.ActivityThread.main(ActivityThread.java:4745) 02-14 12:55:43.541: E/AndroidRuntime(723): at java.lang.reflect.Method.invokeNative(Native Method) 02-14 12:55:43.541: E/AndroidRuntime(723): at java.lang.reflect.Method.invoke(Method.java:511) 02-14 12:55:43.541: E/AndroidRuntime(723): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 02-14 12:55:43.541: E/AndroidRuntime(723): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-14 12:55:43.541: E/AndroidRuntime(723): at dalvik.system.NativeStart.main(Native Method) 02-14 12:55:43.541: E/AndroidRuntime(723): Caused by: java.lang.NullPointerException 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:377) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.LoadedApk.getClassLoader(LoadedApk.java:320) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.LoadedApk.makeApplication(LoadedApk.java:493) 02-14 12:55:43.541: E/AndroidRuntime(723): ... 11 more

I created a simple Android application and it runs properly on Android Emulator. However, when I modify something (adding a variable for instance) and press Run, it sends the apk file to the emulator and it says "Unfortunately MyApplication has stopped working" then restarts it and it works perfectly. I checked the log and it has nothing to do with my application, it complains about some NullException in the APK loader. I restarted the emulator and the Eclipse, too, I use the latest SDK to build my app, my Min API level is 8, target is 16. I do not use native code. I paste the error log here:

02-14 12:55:43.541: E/AndroidRuntime(723): FATAL EXCEPTION: main 02-14 12:55:43.541: E/AndroidRuntime(723): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.LoadedApk.makeApplication(LoadedApk.java:501) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4124) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.ActivityThread.access$1300(ActivityThread.java:130) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.os.Handler.dispatchMessage(Handler.java:99) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.os.Looper.loop(Looper.java:137) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.ActivityThread.main(ActivityThread.java:4745) 02-14 12:55:43.541: E/AndroidRuntime(723): at java.lang.reflect.Method.invokeNative(Native Method) 02-14 12:55:43.541: E/AndroidRuntime(723): at java.lang.reflect.Method.invoke(Method.java:511) 02-14 12:55:43.541: E/AndroidRuntime(723): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 02-14 12:55:43.541: E/AndroidRuntime(723): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-14 12:55:43.541: E/AndroidRuntime(723): at dalvik.system.NativeStart.main(Native Method) 02-14 12:55:43.541: E/AndroidRuntime(723): Caused by: java.lang.NullPointerException 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:377) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.LoadedApk.getClassLoader(LoadedApk.java:320) 02-14 12:55:43.541: E/AndroidRuntime(723): at android.app.LoadedApk.makeApplication(LoadedApk.java:493) 02-14 12:55:43.541: E/AndroidRuntime(723): ... 11 more

最满意答案

您需要在再次启动它之前终止该应用程序。 我不知道有任何其他方法可以做到这一点。 您不能同时运行两个相同的进程。 我的猜测是,它的工作时间很好,但第二次,它没有。

您可以运行模拟器的另一个实例,但不建议这样做。

You need to kill the application before you launch it again. I don't know of any other way to do it. You can't have two of the same process running at the same time. My guess is that the very time it works nice, but second time, it doesn't.

You can mayhaps run another instance of the emulator, but that is NOT recommended.

更多推荐

本文发布于:2023-08-02 22:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1381355.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重新启动   抛出   应用程序   异常   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!