我有一个可以在模拟器和Droid手机上运行的应用程序。在测试LG Optimus(BTW已安装Swype)时,它会崩溃并显示以下堆栈跟踪(注意:它位于EditText的构造函数中)。
奇怪的是,TextView(981)中假定的违规行是getDefualtView(
的方法签名,并且在2.2源代码中没有对EditText或TextView中的GestureDetector的引用。
我假设(或者猜测它很可能是由于Swype)而且我不确定:
感谢任何帮助。
最诚挚的问候, 的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)
- 结束堆栈追踪 -
块引用
答案 0 :(得分:1)
我查看了源代码,似乎在UI线程中调用Looper.prepare()
将修复此异常。但这很奇怪。你在使用多线程吗?