Android studio 1.5.1: Could not find property 'vectorDrawables'

后端 未结 4 380
悲&欢浪女
悲&欢浪女 2021-01-12 09:43

I\'m using Android Studio 1.5.1, Gradle 2.8 and my project min sdk vserion:14, target sdk version: 23.

So, When I add vectorDrawables to configuration by documentat

相关标签:
4条回答
  • 2021-01-12 09:57

    If you’re using v2.0 or above of the Gradle plugin you have to use:

    android {
      defaultConfig {
        vectorDrawables.useSupportLibrary = true
      }
    }
    

    If you hare using v1.5.0 or below of the Gradle plugin you need to add the following to your app’s build.gradle:

    android {
      defaultConfig {
        // Stops the Gradle plugin’s automatic rasterization of vectors
        generatedDensities = []
      }
      // Flag to tell aapt to keep the attribute ids around
      aaptOptions {
        additionalParameters "--no-version-vectors"
      }
    }
    

    Don't confuse gradle with the gradle plugin. Check the build.gradle in the root folder (or inside the module) to get the version used by the gradle plugin (check the line classpath 'com.android.tools.build:gradle:1.5.0')

    0 讨论(0)
  • 2021-01-12 09:57

    Specifically to upgrade from com.android.tools.build:gradle:1.5.0.

    1. Edit /build.gradle and set:

      buildscript {
          ...
          dependencies {
              ...
              classpath 'com.android.tools.build:gradle:2.0.0'
              ...
          }
      }
      
    2. Edit /gradle/wrapper/gradle-wrapper.properties and set:

      distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
      
    3. Edit your module(s)' build.gradle and add:

      android {
          ...
          defaultConfig {
              ...
              vectorDrawables.useSupportLibrary = true
          }
          ...
      }
      
    0 讨论(0)
  • 2021-01-12 10:09

    I experienced this issue with Gradle plugin on v3.4.2. It prevented project sync's from completing.

    The issue was resolved by removing vectorDrawables and adding vectorDrawables.useSupportLibrary = true to the defaultConfig.

    OLD

    android {
        compileSdkVersion 29
        buildToolsVersion "29.0.1"
        defaultConfig {
            applicationId "com.example.android.diceroller"
            minSdkVersion 19
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            vectorDrawables.useSupportLibrary = true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }vectorDrawables
    }
    

    NEW

    android {
        compileSdkVersion 29
        buildToolsVersion "29.0.1"
        defaultConfig {
            applicationId "com.example.android.diceroller"
            minSdkVersion 19
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            vectorDrawables.useSupportLibrary = true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    0 讨论(0)
  • 2021-01-12 10:20

    If u are having useSupportLibary in latest version Use

    vectorDrawables.useSupportLibary(true)
    In your defaultconfig 
    
    0 讨论(0)
提交回复
热议问题