EmptyStackException in Android Layout Editor

Under very specific (and obscure) circumstances, the Android Layout Editor throws an EmptyStackException when the ‘graphical layout’ tab is selected.

The conditions are unlikely to occur, but I did run into this problem yesterday:

subclass TextView to create a custom widget
– create a style for that widget
– specify the text item in the style; not in the widget definition

This may be specific to Android SDK 15; I updated to that release shortly before the problem occurred.

I posted a complete explanation on Stack Overflow at http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds/7943310#7943310 – some of it is repeated below.

I also submitted a bug report to Google’s bug database at http://code.google.com/p/android/issues/detail?id=21375.  I attached a test program to that report; it may be downloaded from the bottom of that page.

The gist of the bug is:

res/layout/main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical">

     <com.ajw.DemoCrashInADT.AutoResizeTextView
         android:id="@+id/resizingText"
         style="@style/myTextStyle"/>

</LinearLayout>

res/values/myStyles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

     <stylename="myTextStyle"parent="@android:style/Widget.TextView">
         <item name="android:layout_height">wrap_content</item>
         <item name="android:layout_width">fill_parent</item>
         <item name="android:text">some message</item>
     </style>

</resources>

With these, open main.xml and select the graphical layout tab.  The exception appears at the bottom of the graphical layout.

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: