工具栏:IllegalStateException-为VectorDrawableCompat配置构建 [英] Toolbar: IllegalStateException - configure your build for VectorDrawableCompat

查看:130
本文介绍了工具栏:IllegalStateException-为VectorDrawableCompat配置构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio 2.1.2.我以19岁的minSdkVersion开始了一个新项目.我的活动扩展了AppCompatActivity.该项目以使用片段的空活动开始.

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.

使用API​​ 24预览content_main.xml时,一切都很好.预览API 19时,出现以下渲染问题:

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

我添加了我发现与gradle相关的所有内容(2个文件):

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"
编译'com.android.support:appcompat-v7:24.1.1'
编译"com.android.support:support-v4:24.1.1"
编译'com.android.support:design:24.1.1

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

但是仍然出现错误.我在互联网上找到了很多答案.但是没有人帮助.将新工具栏与API 19结合使用是否存在问题?

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?

推荐答案

这对我来说效果很好

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"
}

generatedDensities = []

这篇关于工具栏:IllegalStateException-为VectorDrawableCompat配置构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆