References to other resources are not supported by build-time PNG generation

前端 未结 8 1995
陌清茗
陌清茗 2020-12-12 11:25

AndroidStudio 3.0 / Android Gradle plugin 3.0


  

相关标签:
8条回答
  • 2020-12-12 12:19

    Do not use colorReference at fillColor attribute in Vector drawable just use hexa code

    use like this

    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#1abc9c"
        android:pathData="M9,11L7,11v2h2v-2zM13,11h-2v2h2v-2zM17,11h-2v2h2v-2zM19,4h-1L18,2h-2v2L8,4L8,2L6,2v2L5,4c-1.11,0 -1.99,0.9 -1.99,2L3,20c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM19,20L5,20L5,9h14v11z"/>
    

    instead of this

    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="@color/colorPrimary"
        android:pathData="M9,11L7,11v2h2v-2zM13,11h-2v2h2v-2zM17,11h-2v2h2v-2zM19,4h-1L18,2h-2v2L8,4L8,2L6,2v2L5,4c-1.11,0 -1.99,0.9 -1.99,2L3,20c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM19,20L5,20L5,9h14v11z"/>
    

    0 讨论(0)
  • 2020-12-12 12:26

    To support API SDK < 24 add the following line to your app build.gradle inside the android block:

    defaultConfig {
       vectorDrawables.useSupportLibrary = true
    }
    

    If your minSdkVersion is 24 or higher, then your issue will be resolved on its own, because VectorDrawables have full support starting with this API.

    See Android Developers: Vector Drawables Backward Compatibility Solution for details.

    0 讨论(0)
提交回复
热议问题