Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toolbar: IllegalStateException - configure your build for VectorDrawableCompat

I'm using Android Studio 2.1.2. I started a new project with minSdkVersion as 19. My activity extends AppCompatActivity. The project starts with an empty activity using a fragment.

When previewing content_main.xml with API 24, all is good. when previewing API 19, I get the following rendering problem:

 The following classes could not be instantiated:
- android.support.v7.widget.Toolbar
java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat

I have added every thing I found relevant to the gradle (2 files):

classpath 'com.android.tools.build:gradle:2.1.2'
vectorDrawables.useSupportLibrary = true
buildToolsVersion "24.0.1"
compile 'com.android.support:appcompat-v7:24.1.1'
compile "com.android.support:support-v4:24.1.1"
compile 'com.android.support:design:24.1.1

But still the error appears. I've found a lot of answers on internet. But none helped. Is there a problem using the new toolbar with API 19?

like image 827
Amos Avatar asked Aug 10 '16 09:08

Amos


1 Answers

This worked well for me

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.example.app"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    generatedDensities = []
}

// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
    additionalParameters "--no-version-vectors"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

Notice this in the above code:

// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
    additionalParameters "--no-version-vectors"
}

and

generatedDensities = []
like image 155
Diamond Avatar answered Nov 15 '22 03:11

Diamond