Android Robolectric and vector drawables -


i using vector drawables in app v21 , - in resource folder drawable-anydpi-v21 , have fallback bitmap versions other api levels (drawable-hdpi.mdpi,...).

when run robolectric config

@config(sdk = 16, application = myapp.class, constants = buildconfig.class, packagename = "com.company.app") 

i following error on inflate of views using these drawables

caused by: android.content.res.resources$notfoundexception: file ./app/build/intermediates/data-binding-layout-out/dev/debug/drawable-anydpi-v21/ic_info_outline_white_24dp.xml drawable resource id #0x7f02010e caused by: org.xmlpull.v1.xmlpullparserexception: xml file ./app/build/intermediates/data-binding-layout-out/dev/debug/drawable-anydpi-v21/ic_info_outline_white_24dp.xml line #-1 (sorry, not yet implemented): invalid drawable tag vector 

the relevant parts of build.gradle are:

   android {       compilesdkversion 23       buildtoolsversion "23.0.3"       defaultconfig {         applicationid "com.example.app"         minsdkversion 16         targetsdkversion 23         versioncode 79         versionname "0.39"         // enabling multidex support.         multidexenabled true         vectordrawables.usesupportlibrary = true          testapplicationid "com.example.app.test"         testinstrumentationrunner "android.support.test.runner.androidjunitrunner"       }       testoptions {         unittests.returndefaultvalues = true       }    }    dependencies {     compile 'com.android.support:support-vector-drawable:23.4.0'     testcompile "org.robolectric:robolectric:3.1"     testcompile "org.robolectric:shadows-multidex:3.1"     testcompile "org.robolectric:shadows-support-v4:3.1"    } 

so looks though though have specified sdk=16 robolectric seems take drawables drawable-anydpi-v21.

  1. is bug roboelectric? or

  2. is there better way specify apk level is? or

  3. is there way let roboelectric read vector tag? or

  4. some other way of doing it?

do require tests target jellybean?

given require tests target jellybean, may want put v21+ assets in res/drawable-v21 folder instead of res/drawable-anydpi-21.

i getting same error tests after adding imageview layout uses vectordrawable source.

<imageview     android:contentdescription="@string/content_image_description"     android:src="@drawable/banner"     android:layout_gravity="right"     android:layout_width="@dimen/banner_width"     android:layout_height="@dimen/banner_height"     /> 

using robolectric v3.1, able tests pass again following config annotation:

@config(constants = buildconfig.class, sdk = build.version_codes.lollipop, packagename = "com.package") 

hope helps.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -