我正在编辑anandroid应用程序,该应用程序基于我之前曾做过的类似工具。这次它不起作用,但我不知道为什么。
应用程序错误:
The Application Buchanan Java Quiz Game (process hu.csc395.javaquizgame) has stopped unexpectedly Please Try again.
我的日志显示了这个:
04-28 04:31:40.326: D/AndroidRuntime(337): Shutting down VM
04-28 04:31:40.326: W/dalvikvm(337): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-28 04:31:40.395: E/AndroidRuntime(337): FATAL EXCEPTION: main
04-28 04:31:40.395: E/AndroidRuntime(337): java.lang.RuntimeException: Unable to start activity ComponentInfo{hu.csc395.javaquizgame/hu.csc395.javaquizgame.Buchanan_JavaQuizGameActivity}: java.lang.IllegalArgumentException
我不知道这些位置在哪里,所以也许我只是错过它。
Full Logcat,但有例外:
04-28 04:31:40.326: D/AndroidRuntime(337): Shutting down VM
04-28 04:31:40.326: W/dalvikvm(337): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-28 04:31:40.395: E/AndroidRuntime(337): FATAL EXCEPTION: main
04-28 04:31:40.395: E/AndroidRuntime(337): java.lang.RuntimeException: Unable to start activity ComponentInfo{hu.csc395.javaquizgame/hu.csc395.javaquizgame.Buchanan_JavaQuizGameActivity}: java.lang.IllegalArgumentException
04-28 04:31:40.395: E/AndroidRuntime(337): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-28 04:31:40.395: E/AndroidRuntime(337): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-28 04:31:40.395: E/AndroidRuntime(337): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-28 04:31:40.395: E/AndroidRuntime(337): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-28 04:31:40.395: E/AndroidRuntime(337): at android.os.Handler.dispatchMessage(Handler.java:99)
04-28 04:31:40.395: E/AndroidRuntime(337): at android.os.Looper.loop(Looper.java:123)
04-28 04:31:40.395: E/AndroidRuntime(337): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-28 04:31:40.395: E/AndroidRuntime(337): at java.lang.reflect.Method.invokeNative(Native Method)
04-28 04:31:40.395: E/AndroidRuntime(337): at java.lang.reflect.Method.invoke(Method.java:507)
04-28 04:31:40.395: E/AndroidRuntime(337): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-28 04:31:40.395: E/AndroidRuntime(337): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-28 04:31:40.395: E/AndroidRuntime(337): at dalvik.system.NativeStart.main(Native Method)
04-28 04:31:40.395: E/AndroidRuntime(337): Caused by: java.lang.IllegalArgumentException
04-28 04:31:40.395: E/AndroidRuntime(337): at java.util.Random.nextInt(Random.java:186)
04-28 04:31:40.395: E/AndroidRuntime(337): at hu.csc395.javaquizgame.Buchanan_JavaQuizGameActivity.resetQuiz(Buchanan_JavaQuizGameActivity.java:121)
04-28 04:31:40.395: E/AndroidRuntime(337): at hu.csc395.javaquizgame.Buchanan_JavaQuizGameActivity.onCreate(Buchanan_JavaQuizGameActivity.java:85)
04-28 04:31:40.395: E/AndroidRuntime(337): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-28 04:31:40.395: E/AndroidRuntime(337): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-28 04:31:40.395: E/AndroidRuntime(337): ... 11 more
04-28 04:34:37.995: I/Process(337): Sending signal. PID: 337 SIG: 9
我的控制台显示一切正常运行,直到:
[2012-04-28 01:48:17 - Emulator] emulator: WARNING: Unable to create sensors port: Unknown error
[2012-04-28 01:48:17 - Buchanan_JavaQuizGame] New emulator found: emulator-5554
答案 0 :(得分:0)
可能是因为有两个仿真器同时打开。
答案 1 :(得分:0)
在您的代码中的某个位置,您使用nextInt
类的Random
方法,我认为您将其传递为负integer
,这将抛出IllegalArgumentException
(它需要方法参数为正)。
在您的resetQuiz
方法中会发生这种情况,因此请检查您在代码中执行的操作。