Skip to content

[Android] Requiring images with Gradle 4 fails release builds  #16906

@Almouro

Description

@Almouro

Hello guys,

I ran into this issue when updating Gradle and Android Studio.

Thanks for your help!

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 8.5.0
Yarn: 1.3.2
npm: 5.3.0
Watchman: 4.7.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.50.3 => 0.50.3

Target Platform: Android (22)

Steps to Reproduce

Requiring images with latest gradle fails release builds

I created a small test project but here are the steps to reproduce it:

  1. Init a new project: react-native init Test
  2. Update to latest Gradle:
  • Open Android Studio and install recommended version
  • Build from Android Studio, it should ask you to update build tools, do so
  1. Require an image in index.js
  2. Run cd android && ./gradlew assembleRelease

Expected Behavior

The command ./gradlew assembleRelease should not fail

Actual Behavior

Running ./gradlew assembleRelease when the image is required from the JS fails with:

/Users/almouro/bam/uefa/TestGradle3/android/app/build/intermediates/res/merged/release/drawable-mdpi/image.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file..
error: failed parsing overlays.

If the image is not required, the command works fine.

Reproducible Demo

git clone https://github.com/Almouro/react-native-with-gradle-4
yarn
cd android
./gradlew assembleRelease

Workaround

Adding android.enableAapt2=false to android/gradle.properties fixes the issue but it is only a workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Impact: RegressionDescribes a behavior that used to work on a prior release, but stopped working recently.Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.Platform: AndroidAndroid applications.Ran CommandsOne of our bots successfully processed a command.Resolution: FixedA PR that fixes this issue has been merged.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions