我正在使用
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
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 = []