以下是我收到的错误消息:E/AndroidRuntime(416): java.lang.RuntimeException: Unable to start activity ComponentInfo java.lang.IllegalArgumentException
。我拿出了app文件名/包名,但其他一切都在那里。该应用程序旨在针对Gingerbread,但具有Froyo的最低SDK级别。当我尝试在AVD上启动应用程序时,我基本上得到了AVR消息。源代码长约460行,所以我不确定错误在哪里(没有语法错误,所以我不确定我做错了什么)。这是我提供的源代码的pastebin URL:http://pastebin.com/EtUP2CAB。我已经看过一些关于DecimalFormatSymbols和SensorSimulator等的东西,但我仍然感到困惑。因此,我很感激帮助找到导致此错误的问题。
编辑:这是我上次运行的错误日志:
02-03 20:51:21.724: D/AndroidRuntime(468): Shutting down VM
02-03 20:51:21.724: W/dalvikvm(468): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-03 20:51:21.784: E/AndroidRuntime(468): FATAL EXCEPTION: main
02-03 20:51:21.784: E/AndroidRuntime(468): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.deitel.flagquizgame/com.deitel.flagquizgame.FlagQuizGame}: java.lang.IllegalArgumentException
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.os.Looper.loop(Looper.java:123)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-03 20:51:21.784: E/AndroidRuntime(468): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 20:51:21.784: E/AndroidRuntime(468): at java.lang.reflect.Method.invoke(Method.java:507)
02-03 20:51:21.784: E/AndroidRuntime(468): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-03 20:51:21.784: E/AndroidRuntime(468): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-03 20:51:21.784: E/AndroidRuntime(468): at dalvik.system.NativeStart.main(Native Method)
02-03 20:51:21.784: E/AndroidRuntime(468): Caused by: java.lang.IllegalArgumentException
02-03 20:51:21.784: E/AndroidRuntime(468): at java.util.Random.nextInt(Random.java:186)
02-03 20:51:21.784: E/AndroidRuntime(468): at com.deitel.flagquizgame.FlagQuizGame.resetQuiz(FlagQuizGame.java:136)
02-03 20:51:21.784: E/AndroidRuntime(468): at com.deitel.flagquizgame.FlagQuizGame.onCreate(FlagQuizGame.java:92)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-03 20:51:21.784: E/AndroidRuntime(468): ... 11 more
02-03 20:51:27.464: I/Process(468): Sending signal. PID: 468 SIG: 9
答案 0 :(得分:0)
似乎符合
int randomIndex = random.nextInt(numberOfFlags);
numberOfFlags不是正数,0或小于0,通过调试检查numberOfFlags值。