Android studio 1.5.1: Could not find property 'vectorDrawables'

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 documentation Google: Added VectorDrawable support library, I get following error:

  • difference and when to use getApplication(), getApplicationContext(), getBaseContext() and someClass.this
  • Google Play Games Feature Badges not visible at google play
  • android: how to align image in the horizontal center of an imageview?
  • Send a broadcast only to specific Activity
  • MediaPlayer: Couldn't open file on client side; Error(-38,0) and more
  • Error due to invalid combination of Toast and OnClickListener
  • Error:(13, 0) Could not find property 'vectorDrawables' on ProductFlavor_Decorated{name=main, dimension=null, minSdkVersion=ApiVersionImpl{mApiLevel=14, mCodename='null'}, targetSdkVersion=ApiVersionImpl{mApiLevel=23, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptNdkModeEnabled=null, versionCode=25, versionName=1.0.25, applicationId=com.smsoft.alibaba, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}}.
    

    this is my build.gradle file:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            applicationId "com.smsoft.alibaba"
            minSdkVersion 14
            targetSdkVersion 23
            versionCode 25
            versionName "1.0.25"
            vectorDrawables.useSupportLibrary = true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
         compile fileTree(dir: 'libs', include: ['*.jar'])
         testCompile 'junit:junit:4.12'
         compile 'com.android.support:appcompat-v7:23.2.0'
         compile 'com.android.support:design:23.2.0'
         compile 'com.android.support:support-v4:23.2.0'
         compile 'com.android.support:cardview-v7:23.2.0'
    }
    

    Anybody know how to fix this problem ?

    EDIT

    Thanks to @Gabriele Mariotti to signal for my confused between gradle and gradle plugin. I’m confused when reading the addition of Compact Vector Drawables instructions.

    Related posts:

    Which method is being called after popBackStack?
    Android - Same Id for multiple widget
    keyCode on android is always 229
    Android Debug Bridge (adb) device - no permissions
    How can I launch the 'Add Contact' activity in android
    Android: back-up messages and files programmatically
  • How to install USB driver for any android device?
  • Phonegap input type password field focus
  • How to retrieve path to ADB in build.gradle
  • HTML5 navigator.online does not work in WebView
  • How I can get the mime type of a file having its Uri?
  • Android: Reading from file (Openfileinput)
  • 2 Solutions collect form web for “Android studio 1.5.1: Could not find property 'vectorDrawables'”

    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')

    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
          }
          ...
      }
      
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.