首页 > 解决方案 > 构建变体风味维度未覆盖的矢量可绘制对象

问题描述

我有一个带有基本品牌和多个白标品牌以及多个服务器目标的应用程序。在我的应用程序的 build.gradle 中,风味定义为: flavorDimensions("server", "whitelabel")

在我src/main/res/drawable的基础品牌中,我有一个 logo.xml VectorDrawable,它被覆盖在src/whitelabel1/res/drawable.

当我的应用程序的 build.config 包含vectorDrawables.useSupportLibrary = true正确的 logo.xml 时,将在我的 ImageView 中使用。如果我从 Whitelabel1的 apk 中删除useSupportLibraryImageView 呈现logo.xmlmain

<ImageView
    android:id="@+id/imageLogo"
    android:layout_width="@dimen/viewXS"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/marginXS"
    android:adjustViewBounds="true"
    android:padding="@dimen/marginXS"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/ic_logo" />

标签: androidandroid-gradle-pluginandroid-vectordrawablebuild-variant

解决方案


它也发生在我身上。只有在 defaultconfig 中写入此 vectorDrawables.useSupportLibrary = true 之后。矢量资源是从风味源集文件夹中挑选的。


推荐阅读