Monthly Archives: July 2012

Small issue with ADT 20 and SDK 16 and how to fix it

The latest version of the Android Developer Tools (ADT) brought a lot of improvements for us developers. Sadly there is a little quirk coming with it too.

If you have a project targeting API 16/Jelly Bean and you are using ADT 20, you might have some problems with the Graphical Layout tool. Instead of displaying the UI, you may end up with the following screen :

The error message is java.util.LinkedHashMap.eldest()Ljava/util/Map$Entry; which is totally clear… or not.
By looking inside Eclipse, we can find the corresponding complete Stacktrace :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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.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.activated(GraphicalEditorPart.java:1165)
	at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:679)
	at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:359)
	at org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiPageEditorPart.java:1067)

After some research, I found a temporary solution on StackOverflow until this bug is fixed in the next patch of ADT.

The problem seems to be linked to the use of EditText with suggestions in Jelly Bean. On a phone there is no problem but in the Graphical Layout tool it breaks.
We have 2 solutions :

  • Disable the suggestions in the EditText with the inputType textNoSuggestions
    • It fixes the bug but it prevents the users from using the completion in your app. So let’s forget about it and look at the other solution
  • Switch the Graphical Layout to a different API (for example ICS/15 which is nearly the same as JB in terms of UI)

To do that, you just need to use the little droid on the top right and switch to 15 as shown in the screenshot below.

And voila ! :)

Update :
Xavier Ducrohet (who is working on the ADT tool) replied to my post on Google + and told me that the issue doesn’t come from ADT 20 but from the rendering library of Jelly Bean. So if I understand right, we need to wait for an update of JB to have a fix.

Update 2 :
The fix is available in ADT 20.0.1 ! So update the following elements and it will be good :

  • ADT Plugin in version 20.0.1
  • Android SDK Tools 20.0.1
  • Android SDL 16 rev 2

If you don’t see them, clear the cache of the SDK manager in the options

Page optimized by WP Minify WordPress Plugin