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

excursions into Android development

I’ve started doing some Android development on my own apps.  It’s been interesting – some genuinely and some in the “oh, God! oh, God! We’re all gonna die!” interesting.

I’ll post more about it soon – especially some of the tips I’ve discovered  (or, more accurately, stumbled across…   :)

%d bloggers like this: