0

我正在编辑一个基于我之前做过的类似应用的安卓应用。这次它不起作用,但我不知道为什么。

应用程序错误:

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

我不知道这些在哪里,所以也许我只是想念它。

完整的 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
4

2 回答 2

0

可能是因为同时打开了两个模拟器。

于 2012-04-28T06:16:44.733 回答
0

在您的代码中的某处,您使用了类的nextInt方法,Random我认为您将其传递给负数integer,这将抛出IllegalArgumentException(它要求方法参数为正数)。

这发生在您的resetQuiz方法中,因此请检查您在代码中所做的事情。

于 2012-04-28T06:50:24.573 回答