我在我的應用程序中使用了一些矢量繪圖,但僅適用於v21及更高版本 - 它們位於資源文件夾drawable-anydpi-v21中,並且還具有用於其他api級別的回退位圖版本(drawable-hdpi .mdpi,...)。Android Robolectric和矢量繪圖
當我運行一個robolectric這個配置
@Config(sdk = 16, application = MyApp.class, constants = BuildConfig.class, packageName = "com.company.app")
我使用這些可繪製
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
中的build.gradle的相關部分得到的意見充氣以下錯誤是:
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"
}
所以它看起來好像即使我指定sdk = 16 Robolectric似乎t從drawable-anydpi-v21中獲取drawables。
這是一個bug是roboelectric?或者
有更好的方法來指定APK級別是什麼嗎?或
有沒有辦法讓船電閱讀矢量標籤?或
其他一些做法呢?
你可以顯示你的'build.gradle'嗎?爲了確保你如何使用矢量繪圖 –
build.gradle添加 – siliconeagle
它不工作像這樣你有'defaultConfig vectorDrawables.useSupportLibrary = true }'? –