Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop working project with vector drawables after update build.gradle on API < 21

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

like image 346
Yura Shinkarev Avatar asked Jul 12 '17 11:07

Yura Shinkarev


2 Answers

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

like image 53
Yura Shinkarev Avatar answered Oct 05 '22 21:10

Yura Shinkarev


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

like image 44
DeKaNszn Avatar answered Oct 05 '22 19:10

DeKaNszn