Stop working project with vector drawables after u

2020-04-03 13:16发布

I have working project.

  • minSdkVersion 17
  • com.android.tools.build:gradle:2.3.3
  • gradle 4.1
  • Android Studio 3 Canary 6

I have in my gradle files:

defaultConfig {
        vectorDrawables.useSupportLibrary = true
        vectorDrawables.generatedDensities = []
}

I call in activity too:

AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)

Application works perfectly. Now change to:

  • com.android.tools.build:gradle:3.0.0-alpha6
  • add to repositories google() line

Execute gradle clean assembleDebug.

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).

Why?

UPD 2017-07-19: It was fixed and released in com.android.tools.build:gradle:3.0.0-alpha7

3条回答
迷人小祖宗
2楼-- · 2020-04-03 13:30

I am facing the same problem, downgrade Android Studio to previous version canary5 and write the following in your build.gradle

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
    ...
查看更多
闹够了就滚
3楼-- · 2020-04-03 13:37

I'm add to gradle.properties line

android.enableAapt2=false

and it's solve my error.

UPD 2017-07-19: It was fixed and released in com.android.tools.build:gradle:3.0.0-alpha7

查看更多
老娘就宠你
4楼-- · 2020-04-03 13:45

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

Also from release notes to alpha5:

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

查看更多
登录 后发表回答