4

I have an app which works in the emulator and on Droid phones. While testing on an LG Optimus (which BTW has Swype installed) it crashes with the following stack trace (NOTE: it is in the constructor of EditText).

What is weird is that supposed offending line in TextView (981) is the method signature for getDefualtView() and there are no references to GestureDetector in EditText or TextView in 2.2 source code.

I'm presuming (or hazarding a guess that it is most likely due to Swype) and am not sure of:

  1. if it is swype, then how do i write my code so that it is swype friendly?
  2. if it is not swype, then what could it be? Whats baffling is that it is in the constructor using default styles, and null for attributes.

any help is appreciated.

Kindest regards, S-

-- stacktrace snip --

05-26 12:28:23.440: ERROR/AndroidRuntime(11912): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.os.Handler.<init>(Handler.java:121)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.view.GestureDetector$GestureHandler.<init>(GestureDetector.java:250)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.view.GestureDetector.<init>(GestureDetector.java:370)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.view.GestureDetector.<init>(GestureDetector.java:347)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.view.GestureDetector.<init>(GestureDetector.java:331)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.widget.TextView.<init>(TextView.java:981)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.widget.EditText.<init>(EditText.java:55)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.widget.EditText.<init>(EditText.java:51)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at android.widget.EditText.<init>(EditText.java:47)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.EditTextImpl.<init>(EditTextImpl.java:28)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.TextFieldImpl.makeTextView(TextFieldImpl.java:23)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.ToolkitImpl.createTextField(ToolkitImpl.java:429)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.ToolkitImpl.createWidgets(ToolkitImpl.java:492)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.android.gui.ToolkitImpl.initializeContainer(ToolkitImpl.java:555)
05-26 12:28:23.440: ERROR/AndroidRuntime(11912):     at com.mobiapps.common.gui.WidgetContainer.initializeImpl(WidgetContainer.java:88)

-- end stack trace --

Blockquote

Sheshadri Mantha
  • 491
  • 5
  • 14
  • Can you post code? You say that the crash comes from the declaration of EditText, can we see that and the actual offending lines? – Nicholas May 26 '11 at 20:50
  • Disabled Swype and still getting error. Checking into why am getting Looper error now... – Sheshadri Mantha May 26 '11 at 23:55
  • @Nicholas - here is code snippet: `public class EditTextImpl extends EditText implements FieldAssignListener, FieldImpl { private WidgetContainer container; private Value widget; private AttributeImpl attributes; private Value objectForNewValue; private Member memberForNewValue; private int assignedWidth; private String value; public EditTextImpl(Activity context, WidgetContainer container, Value widget, AttributeImpl attributes) { super(context); this.container = container; this.widget = widget; this.attributes = attributes;` Oh! This gets invoked on an AsyncTask – Sheshadri Mantha May 26 '11 at 23:57

1 Answers1

1

I looked into sources and it seems that invoking Looper.prepare() in the UI thread will fix this exeption. But it's very strange. Are you using multiple threads?

pawelzieba
  • 16,082
  • 3
  • 46
  • 72
  • 1
    Yes it was in a different thread; And adding a Looper.prepare() does fix it. Wondering why it works on EMulator and Droid w/o prepare(). – Sheshadri Mantha May 27 '11 at 00:57