I use some vector drawings in my application, but only for v21 and higher - they are in the drawable-anydpi-v21 resources folder, and also have versions of rollback bitmaps for other api levels (drawable-hdpi.mdpi, ...).
When I run robolectric with this configuration
@Config(sdk = 16, application = MyApp.class, constants = BuildConfig.class, packageName = "com.company.app")
I get the following error when inflating views with these drawings
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 from 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, it seems that although I specified sdk = 16, Robolectric seems to be taking the drawings from drawable-anydpi-v21.
Is this a roboelectric bug? or
Is there a better way to indicate what the level of the APK is? or
Is there a way for roboelectric to read a vector tag? or
Any other way to do this?
android robolectric android-vectordrawable
siliconeagle
source share