android – 工具栏:IllegalStateException – 为VectorDrawableCompat配置你的构建

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

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

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个文件):

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的新工具栏是否有问题?

解决方法

这对我很有用
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'
    }
}

}

请注意以上代码

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

generatedDensities = []

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...