在API<上更新build.gradle之后,停止使用矢量可绘制项目进行工作. 21岁 [英] Stop working project with vector drawables after update build.gradle on API < 21
问题描述
我有工作项目.
- minSdkVersion 17
- com.android.tools.build:gradle:2.3.3
- 4.1级
- Android Studio 3 Canary 6
我的gradle文件中有
I have in my gradle files:
defaultConfig {
vectorDrawables.useSupportLibrary = true
vectorDrawables.generatedDensities = []
}
我也参加活动:
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
应用程序完美运行.现在更改为:
Application works perfectly. Now change to:
- com.android.tools.build:gradle:3.0.0-alpha6
- 添加到存储库
google()
行
执行gradle clean assembleDebug
.
应用继续可在API> 20的设备上运行.但是对于API< 21(Google Android模拟器)在启动应用程序时崩溃.
我在logcat错误中看到:Resources$NotFoundException: Resource ID #0x7f080058
(0x7f080058是可绘制的abc_vector_test).
App continue works on devices with API > 20. But for API < 21 (google android emulator) get crash on start application.
I see in logcat error: Resources$NotFoundException: Resource ID #0x7f080058
(0x7f080058 is drawable abc_vector_test).
为什么?
UPD 2017-07-19 :它已在com.android.tools.build:gradle:3.0.0-alpha7中修复并发布
UPD 2017-07-19: It was fixed and released in com.android.tools.build:gradle:3.0.0-alpha7
推荐答案
第3版中的Gradle插件使用新的AAPT,但存在一些错误.
在阅读了有关Bug跟踪器的一些问题之后,我发现Gradle具有完全禁用AAPT2的选项:android.enableAapt2=false
Gradle plugin from version 3 use new AAPT, that have some bugs.
After reading some issues on bug tracker, I've found that Gradle has option for full disable AAPT2: android.enableAapt2=false
从发行说明到alpha5:
Also from release notes to alpha5:
AAPT2.我们将继续稳定AAPT2,以实现增量资源处理.如果由于资源构建失败 处理问题,请向我们发送错误报告.暂时禁用 AAPT,在gradle.properties文件中设置android.enableAapt2 = false.
Roboelectric当前与AAPT2不兼容
AAPT2. We are continuing to stabilize AAPT2 which enables incremental resource processing. If your build fails due to resource processing issue, please send us a bug report. To temporarily disable AAPT, set android.enableAapt2=false in your gradle.properties file.
Roboelectric is currently not compatible with AAPT2
这篇关于在API<上更新build.gradle之后,停止使用矢量可绘制项目进行工作. 21岁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!