Categories
Tech

Android TV: GuidedStep InflateException

I’ve working on porting SharpTools, my Android home automation app, to Amazon Fire TV and Android TV using the Google Leanback library and ran into a snag today. After building a GuidedStepFragment, I was getting the error “Unable to start activity ComponentInfo{}: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: You must supply a layout_width attribute.

At first, I was a bit baffled as the developer guidelines clearly state that GuidedStepFragments should be added programmatically and not via XML files and there weren’t any clear references to our control over the XML file. I took a quick peek at the manifest from the androidtv-Leanback example and quickly realized the difference – they were explicitly specifying the theme in the activity declaration. In their example, they were using a modified theme, but in my case I simply added the theme attribute with the default Theme.Leanback.GuidedStep and everything started working as expected.

<activity
android:name=".tv.TVSetup"
android:label="@string/action_settings"
android:theme="@style/Theme.Leanback.GuidedStep">

Leave a Reply

Your email address will not be published. Required fields are marked *