0

I've run into an error from an online testing facility while doing monkey test, but since the online facility did the testing and generated this error, I am not sure how it comes and what does it mean. I can most far look at it and say that it has something to do with the Dialog box display, but I'm not sure.

Can anyone make out from this and let me know what could be the exact issue causing this ?

monkeyExercise({eventCount: 5000, throttle: 5, seed: 0})

CRASH: com.company.apppackage (pid 2306)
Short Msg: java.lang.IllegalArgumentException
Long Msg: java.lang.IllegalArgumentException: View not attached to window manager
Build Label: generic_x86/sdk_x86/generic_x86:4.3/JSS15J/eng.android-build.20130801.155736:eng/test-keys
Build Changelist: eng.android-build.20130801.155736
Build Time: 1375343923000
java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:406)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:308)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:79)
at android.app.Dialog.dismissDialog(Dialog.java:323)
at android.app.Dialog.dismiss(Dialog.java:306)
at com.company.apppackage.util.AppProgressDialog$PGTask.onPostExecute(AppProgressDialog.java:177)
at com.company.apppackage.util.AppProgressDialog$PGTask.onPostExecute(AppProgressDialog.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

** Monkey aborted due to error.
Events injected: 2445
## Network stats: elapsed time=18186ms (18166ms mobile, 0ms wifi, 20ms not connected)
** System appears to have crashed at event 2445 of 5000 using seed 1393545256246
CodenameLambda1
  • 1,299
  • 7
  • 17

1 Answers1

0

The problem is that the dialog is not showing when dismiss() is called. You are dismissing the dialog when an AsyncTask (class PGTask), not from a user event. Try changing the code in onPostExecute from:

dialog.dismiss();

to

if (dialog.isShowing()) {
    dialog.dismiss();
}

EDIT: If the above does not fix the problem, another possibility is that the activity is being destroyed before the dialog is dismissed. (This can easily happen, for instance, if the device is reoriented while the dialog is being shown, or if you call finish().) There are a couple of fixes possible here.

The first (and perhaps cleanest) would be to avoid explicitly showing and dismissing the dialog and instead let the activity do it. Your onPostExecute could then be modified to something like:

activity.dismissDialog(DIALOG_ID);

(where activity is a reference to your activity and DIALOG_ID is an int you define for this particular dialog). You would need to also modify the code that shows the dialog (in onPreExecute?) to:

activity.showDialog(DIALOG_ID);

and you would need to set up the activity's onCreateDialog (and perhaps onPrepareDialog) to deal with DIALOG_ID.

Another possibility is to override the activity's onDestroy() method to dismiss the dialog. See this thread for examples of how to do that.

Community
  • 1
  • 1
Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
  • Hi Ted, thanks for your response. the if condition "isShowing()" is already there in the code before dismissal. Still its getting crashed. – CodenameLambda1 Mar 17 '14 at 15:11
  • @CodenameLambda1 - I think then that the problem is that your activity no longer exists when the dialog is dismissed. I updated my answer to address this. Does the app crash all the time or only occasionally? – Ted Hopp Mar 17 '14 at 15:55
  • Thanks for the update. Yes, the activity din't exist before the dialog was dismissed. Got it solved now. I placed the call to dimiss dialog before the starting call to new activity. – CodenameLambda1 Mar 17 '14 at 16:58