Search code examples
androidandroid-4.2-jelly-bean

4.1: XML Layout LinkedHashMap error


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingLeft="10dp"
        android:paddingRight="10dp">
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Some Text"
            android:layout_margin="5dp"
            android:textSize="22sp"
            />
        <View
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:background="@android:color/black"
            />
        <EditText
            android:id="@+id/edit_firstname"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:inputType="text"
            />
    </LinearLayout>
</LinearLayout>

I have this XML Layout above, everything is working fine in 4.0.3, but when I apply it to 4.1, it produces this error below. When I removed EditText layout is fine.

enter image description here


Solution

  • It's an issue right now It doesn’t come from ADT 20 but from the rendering library of Jelly Bean. So We need to wait for an update of JB to have a fix.

    But as a workaround, we are able to solve this by disabling the SpellChecker.

    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)
    

    So add android:inputType="textNoSuggestions" to your EditText and you will get this problem resolved.

    For more details see this link.