【发布时间】:2016-06-28 10:54:45
【问题描述】:
我在我的应用程序中使用了一些矢量可绘制对象,但仅适用于 v21 及更高版本 - 它们位于资源文件夹 drawable-anydpi-v21 中,并且还有其他 api 级别的后备位图版本(drawable-hdpi.mdpi,.. .).
当我使用此配置运行机器人时
@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 似乎也从 drawable-anydpi-v21 中获取了可绘制对象。
这是一个机器人电动虫吗?或
有没有更好的方法来指定 APK 级别是什么?或
有没有办法让 roboelectric 读取矢量标签?或
还有其他方法吗?
【问题讨论】:
-
你能显示你的
build.gradle吗?确定如何使用矢量绘图 -
已添加build.gradle
-
这样不行你有
defaultConfig { vectorDrawables.useSupportLibrary = true }吗? -
哇!实际上这就是我所拥有的,但我删除了错误的行。我已经更新了
-
解决了吗,写下你的答案
标签: android robolectric android-vectordrawable