Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using layer-list with selector item #2680

Closed
nathanielwolf opened this issue Oct 13, 2016 · 1 comment
Closed

Error when using layer-list with selector item #2680

nathanielwolf opened this issue Oct 13, 2016 · 1 comment

Comments

@nathanielwolf
Copy link

nathanielwolf commented Oct 13, 2016

Description

I get the following error when inflating a Fragment that contains a view with a layer-list drawable background:

Caused by: org.xmlpull.v1.XmlPullParserException: XML file /Users/nwolf/dev/main/app/../app/build/intermediates/data-binding-layout-out/dev/debug/drawable-v21/list_item_selector.xml line #-1 (sorry, not yet implemented): tag requires a 'drawable' attribute or child tag defining a drawable

Steps to Reproduce

Inflate fragment with View that include a background list_item_selector.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <selector>
            <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
            <item android:drawable="@color/station_list_item_selected" android:state_pressed="false"
                  android:state_selected="true"/>
            <item android:state_focused="true"  android:state_enabled="false" android:state_pressed="true" android:drawable="@color/station_list_item_focused" />
            <item android:drawable="@color/station_list_item_disabled" android:state_enabled="false"
                  android:state_focused="true"/>
            <item android:drawable="@color/station_list_item_selected_pressed"
                  android:state_pressed="true"
                  android:state_selected="true"/>
            <item android:drawable="@color/station_list_item_pressed" android:state_focused="true"
                  android:state_pressed="true"/>
            <item android:drawable="@color/station_list_item_pressed" android:state_focused="false"
                  android:state_pressed="true"/>
            <item android:drawable="@color/station_list_item_focused" android:state_focused="true"/>
            <item android:drawable="@color/transparent"/>
        </selector>
    </item>
    <item android:drawable="?android:attr/selectableItemBackground" />
</layer-list>

Robolectric & Android Version

robolectic 3.1.2 - targeting SDK 21

@jongerrish
Copy link
Contributor

We've revamped resources in Robolectric 4.0 to process the binary resource files + arsc table produced by aapt and the resource handling code is now much closer to that of the framework. This includes changes to parse the merged manifest using the Android platform code.

Mind giving this a try with 4.0 + binary resources by configuring your gradle.build as follows:-

testImplementation "org.robolectric:robolectric:4.0"

android {
  enableUnitTestBinaryResources=true
  testOptions {
    unitTests {
      includeAndroidResources = true
    }
  }
}

We're doing a big bug scrub and trying to be aggressive about it so apologies if this was closed in error, in which case feel free to reopen.

If this is still an issue an example project with failing test would be most helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants