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

Similar Posts:

Leave a comment ?

14 Comments.

  1. That was helpful. Good to know. I’ll target API level 15 for now.

  2. We just pushed the fix, alongside tools 20.0.1

  3. Foxykeep (47 comments)

    Thanks for the update :)

  4. mattias topse (2 comments)

    what if updating to 20.0.1 doesn’t fix the issue?

  5. Foxykeep (47 comments)

    Yes I tested this morning and it doesn’t fix the issue :/

    I’ve contacter Xavier about it so wait & see

  6. I tried it and it works. Make sure that you also update the SDK Platform for API 16 to rev 2 as that’s the package that contains the rendering library for API 16.
    Just updating ADT is NOT enough.

  7. Foxykeep (47 comments)

    After checking, the issue was the cache in the SDK manager which hid me the new elements :)

  8. mattias topse (2 comments)

    hey, yeah i’m not quite sure. in my SDK manager, it says I have Google API’s 16 rev. 2. That was the first place I went to do an update. Then in the Eclipse help window I can see the android tools are set to 20.0.1. But when I go to the graphical view, I still see the message java.util.LinkedHashMap.eldest()Ljava/util/Map$Entry;

    How do I reset/clear the SDK manager cache?

  9. Foxykeep (47 comments)

    In the SDK Manager, go to Tools>Options and use the Clear cache button

  10. Paul (1 comments)

    Merci !!!!

  11. Ketan (1 comments)

    I am using ADT 20.0.2 and SDK Revision 20 but I am getting the following error.

    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: already added: Lcom/google/gdata/util/common/base/Preconditions;
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.command.dexer.Main.processClass(Main.java:486)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.command.dexer.Main.processOne(Main.java:418)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.dx.command.dexer.Main.run(Main.java:206)
    [2012-07-27 15:21:48 - ProjectName] Dx at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [2012-07-27 15:21:48 - ProjectName] Dx at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [2012-07-27 15:21:48 - ProjectName] Dx at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [2012-07-27 15:21:48 - ProjectName] Dx at java.lang.reflect.Method.invoke(Method.java:597)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:180)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:703)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:577)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.internal.resources.Project.build(Project.java:124)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1000)
    [2012-07-27 15:21:48 - ProjectName] Dx at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:147)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:855)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:704)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1047)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1251)
    [2012-07-27 15:21:48 - ProjectName] Dx at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
    [2012-07-27 15:21:51 - ProjectName] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
    (org.ccil.cowan.tagsoup.Parser$1) that doesn’t come with an
    associated EnclosingMethod attribute. This class was probably produced by a
    compiler that did not target the modern .class file format. The recommended
    solution is to recompile the class from source, using an up-to-date compiler
    and without specifying any “-target” type options. The consequence of ignoring
    this warning is that reflective operations on this class will incorrectly
    indicate that it is *not* an inner class.
    [2012-07-27 15:21:52 - ProjectName] Dx 1 error; aborting
    [2012-07-27 15:21:52 - ProjectName] Conversion to Dalvik format failed with error 1

    In My project, I have 5 3rd party jar library.

  12. Foxykeep (47 comments)

    No idea why this happens. Create a new post on the ADT Google Groups (https://groups.google.com/forum/?fromgroups#!forum/adt-dev).
    The ADT dev are looking at it really regularly and they will have more answers than me

  13. Alfi (1 comments)

    Thanks this solution did fix my problem, but in my case it was nothing to do with EditText or its properties. My manifest was targeting SDK 15 and my eclipse xml graphical layout was set to 16. I was getting the same error message, just switched it to 15

  14. Thanks. Helpful

Leave a Reply

Page optimized by WP Minify WordPress Plugin