Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I drag a "Plain Text" field over to my WYSIWYG editor in Eclipse for Android 4.1 I get a Java crash - How do I fix this?

I'm on a Mac with the latest Java installed. I have Eclipse 4.2.0 installed and just downloaded Jelly Bean 4.1 (API 16) SDK. Everything is up to date.

I start a new project and use all of the default templates and values. I just call my app something simple like "MyApp".

When I drag a button over from the Toolbox to the WYSIWYG editor, the button shows up fine, I can edit the XML and everything is fine, etc etc.

But when I drag over a Plain Text box I get the following Java error and my entire WYSIWYG editor goes grey. The only way I can get it back to the way it was is if I delete the code from the XML and restart Eclipse. If I paste the code back in, the error comes back.

Here is the error:

java.util.LinkedHashMap.eldest()Ljava/util/Map$Entry;
Exception details are logged in Window > Show View > Error Log

And here is the code that is causing it:

<EditText
    android:id="@+id/editText1"
    android:inputType="text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignTop="@+id/button1"
    android:layout_marginLeft="55dp"
    android:ems="10"
    android:hint="@string/hello_world" >

    <requestFocus />
</EditText>

I understand Jelly Bean is brand new today, but does anyone have any ideas on what may be going on here?

Can anyone else repro this problem?

By the way, I DO NOT get a crash with other text field types, like Password, Person Name, etc. Only with Plain Text.

EDIT:

Here's the stack trace from Eclipse:

java.lang.NoSuchMethodError: java.util.LinkedHashMap.eldest()Ljava/util/Map$Entry;
at android.util.LruCache.trimToSize(LruCache.java:206)
at android.util.LruCache.evictAll(LruCache.java:306)
at android.widget.SpellChecker.resetSession(SpellChecker.java:141)
at android.widget.SpellChecker.setLocale(SpellChecker.java:147)
at android.widget.SpellChecker.<init>(SpellChecker.java:112)
at android.widget.Editor.updateSpellCheckSpans(Editor.java:461)
at android.widget.Editor.onAttachedToWindow(Editor.java:212)
at android.widget.TextView.onAttachedToWindow(TextView.java:4455)
at android.view.View.dispatchAttachedToWindow(View.java:11755)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2424)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2424)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2424)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2424)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:37)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:329)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:331)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:372)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1640)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1391)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.onXmlModelChanged(GraphicalEditorPart.java:1353)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegateXmlModelChanged(LayoutEditorDelegate.java:395)
at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.xmlModelChanged(CommonXmlEditor.java:328)
at com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor$XmlModelStateListener.modelChanged(AndroidXmlEditor.java:1610)
at com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor.wrapEditXmlModel(AndroidXmlEditor.java:1084)
at com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor.wrapUndoEditXmlModel(AndroidXmlEditor.java:1160)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.MoveGesture.drop(MoveGesture.java:393)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GestureManager$CanvasDropListener.drop(GestureManager.java:652)
at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4134)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1271)
at org.eclipse.swt.dnd.DropTarget.drop(DropTarget.java:726)
at org.eclipse.swt.dnd.DropTarget.performDragOperation(DropTarget.java:740)
at org.eclipse.swt.dnd.DropTarget.dropTargetProc(DropTarget.java:454)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSView.dragImage(NSView.java:150)
at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:397)
at org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:218)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4134)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1271)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3980)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3619)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:585)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:540)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

and here's my session info:

eclipse.buildId=I20120608-1400
java.version=1.6.0_33
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -keyring /Users/ethanallen/.eclipse_keyring -showlocation
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -keyring /Users/ethanallen/.eclipse_keyring -showlocation
like image 345
Ethan Allen Avatar asked Jun 28 '12 00:06

Ethan Allen


3 Answers

I think you may need to add the following to your EditText (until the tools are updated for the newest API to solve this bug).

 android:inputType="textNoSuggestions"

see my response here: https://stackoverflow.com/a/11276651/1449799

like image 135
Michael Avatar answered Nov 10 '22 12:11

Michael


Confirmed bug: http://code.google.com/p/android/issues/detail?id=33789

like image 21
Ethan Allen Avatar answered Nov 10 '22 13:11

Ethan Allen


I test the textNoSuggestions but it doesn't work.

But, when I set the:

android:inputType = "textPersonName"

It works well! Please try it.

like image 23
xff1874 Avatar answered Nov 10 '22 14:11

xff1874