Amo*_*mos 6 android android-toolbar
我正在使用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
Run Code Online (Sandbox Code Playgroud)
我添加了我发现的与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
Run Code Online (Sandbox Code Playgroud)
但仍然出现错误.我在互联网上找到了很多答案.但没有人帮助.使用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'
}
}
Run Code Online (Sandbox Code Playgroud)
}
请注意以上代码:
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
Run Code Online (Sandbox Code Playgroud)
和
generatedDensities = []
Run Code Online (Sandbox Code Playgroud)
来自这个谷歌问题
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
Run Code Online (Sandbox Code Playgroud)
检查此问题以获得更多帮助。
更新
配置您的应用程序build.gradle文件如下
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
}
Run Code Online (Sandbox Code Playgroud)
向量的来源 时代