Skip to content

uncompiled PNG file passed as argument. Must be compiled first into .flat file.. error: failed parsing overlays. #4755

Closed
@RameshSain

Description

@RameshSain

In android release build.
while creating release build in android.

Its really painful : - please help me to sort it out.

all available solution is not working for me .

Using command line cd android && ./gradlew assembleRelease
mac os : 10.13.1
android studio :3.1.3
React-native : 0.55.3

Activity

brentvatne

brentvatne commented on Jul 24, 2018

@brentvatne
Member
Sim923

Sim923 commented on Jul 25, 2018

@Sim923

But when I try with android.enableAapt2=false... I am getting following warnings

The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..

And I can't execute the app as the debug mode with following error.

Failed to execute aapt

Could you please help me?

Sim923

Sim923 commented on Jul 25, 2018

@Sim923

And when I try to build the signed apk - ./gradlew assembleRelease
I can build the apk with android.enableAapt2=false

But when install apk and execute it some features are not working
1.react native geolocation
2.https://www.npmjs.com/package/react-native-location-switch
And this is not working either and when I try enable location, app is always crushed

ggdegreat

ggdegreat commented on Aug 9, 2018

@ggdegreat

android.enableAapt2=false only for a workaround and its not recommended. Should waiting for them to release an official fixed on this issue.

NaleenDissanayake

NaleenDissanayake commented on Aug 13, 2018

@NaleenDissanayake

I'm also in trouble with that.

jayfour000

jayfour000 commented on Aug 15, 2018

@jayfour000

Why was this issue closed? It is still a blocking issue for me.

NaleenDissanayake

NaleenDissanayake commented on Aug 15, 2018

@NaleenDissanayake

yes. This is the solution for this android.enableAapt2=false

mekaVR

mekaVR commented on Sep 3, 2018

@mekaVR

is not a solution @NaleenDissanay but a circumvention of the problem.
I have the same problem.

NaleenDissanayake

NaleenDissanayake commented on Sep 3, 2018

@NaleenDissanayake

But it works however

bekchan

bekchan commented on Sep 4, 2018

@bekchan

Same problem.
android.enableAapt2=false helps, but build give this message

Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..

I think we need another solution

RameshSain

RameshSain commented on Sep 4, 2018

@RameshSain
Author

1.Delete the tmp files of the images that were created during the build process. (in tmp\YOURAPP\app\intermediates\res\merged\release\drawable....). The exact path is given by the compiler error.
2.Search for files that have a @-suffix different from @2x or @3x in your app folder and delete them. 3.See https://facebook.github.io/react-native/docs/images.html
4.Sometimes the issue stems from images of a module you use. Search for the images with wrong suffix in the respective node_modules folder and delete them.
DON'T USE the common workaround (which consists in disabling aapt2).

ADDITION you may be using different format of assets for example 1. image.jpg instead of image.png

mekaVR

mekaVR commented on Sep 4, 2018

@mekaVR

@bearty
I upgraded gradle version https://gradle.org/install/
and added this in my android/build.gradle

subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
}
}
}
}

and it's work with android.enableAapt2=true

EDIT of 09-19-2018
delete the images in the node_modules the images that block the build and delete the piece of code above in the android/build.gradle

jdegger

jdegger commented on Sep 19, 2018

@jdegger

@mekaVR what gradle version are you on?

mekaVR

mekaVR commented on Sep 19, 2018

@mekaVR

hi @jdegger my solution posted 15 days ago is not stable. The only solution I found that works every day and delete in the node_modules the images that block the build, and remove the piece of code I posted earlier in android/build.gradle.

My gradle version

------------------------------------------------------------
Gradle 4.10
------------------------------------------------------------

Build time:   2018-08-27 18:35:06 UTC
Revision:     ee3751ed9f2034effc1f0072c2b2ee74b5dce67d

Kotlin DSL:   1.0-rc-3
Kotlin:       1.2.60
Groovy:       2.4.15
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          1.8.0_181 (Oracle Corporation 25.181-b13)
OS:           Linux 3.10.0-862.11.6.el7.x86_64 amd64

I hope this will help you

3 remaining items

motogod

motogod commented on Sep 24, 2018

@motogod

Hi @mekaVR . Thanks for respond, In my error:

/Users/motogod19/ReactNativeTutorial/MovieToGo/android/app/build/intermediates/res/merged/release/drawable-xhdpi/node_modules_teaset_icons_success.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file.. error: failed parsing overlays.

,I try to delete the folder drawable-xhdpi when I type cd android && ./gradlew assembleRelease . It looks like the foler re-create and stills show the same error.

mekaVR

mekaVR commented on Sep 24, 2018

@mekaVR

don't delete the folder juste img without prefix @x if I'm wrong the way is node_modules/teaset/icons/success.png or node_modules/teaset_icons/success.png no ? after deleting the image do not forget to delete where it is called in the code of the same module and do not forget to make a ./gradlew clean before ./gradlew assembleRelease

I hope I was able to help you

motogod

motogod commented on Sep 25, 2018

@motogod

Thnkas @mekaVR , it's really helpful from your help.

EDIT My solution of 09-25-2018

Dlete the images success.png smile.png stop.png info.png indicator.png under the path node_modules/teaset/icons/ (Depends on what is your error image) and where it is called in the code.

build apk will see another png error:
node_modules_reactnavigationstack_dist_views_assets_backicon.png

Add android.enableAapt2=false in gradle.properties and build apk again will see next error node_modules_reactnavigationstack_dist_views_assets_backicon.png: error: **Duplicate file**.

Change assetPathUtil.js file code:
before:

function getAndroidAssetSuffix(scale: number): string {
   switch (scale) {
     case 0.75: return 'ldpi';
     case 1: return 'mdpi';
     case 1.5: return 'hdpi';
     case 2: return 'xhdpi';
     case 3: return 'xxhdpi';
     case 4: return 'xxxhdpi';
   }
   throw new Error('no such scale');
}

after:

// fix upgrade android gradle version from 2 to 3 
function getAndroidAssetSuffix(scale) {
   switch (scale) {
      case 0.75: return 'ldpi-v4';
      case 1: return 'mdpi-v4';
      case 1.5: return 'hdpi-v4';
      case 2: return 'xhdpi-v4';
      case 3: return 'xxhdpi-v4';
      case 4: return 'xxxhdpi-v4';
   }
}

The file path is node_modules\react-native\local-cli\bundle\assetPathUtils.js

Delete the folder android/app/build/intermediates/res/merged/release/drawable-xhdpi. It will cause the duplicate error if your gradle version upgrade to 3.

That's it and don't forget ./gradlew clean before ./gradlew assembleRelease.

Hope it can helps someone too.

Thanks for @mekaVR help again.

added a commit that references this issue on Oct 2, 2018
doomsower

doomsower commented on Oct 5, 2018

@doomsower
Contributor

So the upstream issue facebook/react-native#16906 seems to be fixed, but it still doesn't work for me in RN0.57.2 without android.enableAapt2=false

michaelknoch

michaelknoch commented on Nov 22, 2018

@michaelknoch

still facing this issue in rn 0.57.5

GaneshSaiKumar

GaneshSaiKumar commented on Nov 29, 2018

@GaneshSaiKumar

@motogod
this solution is working sometimes and failing some times
i'm using gradle 4.6
build tools 3.1.0
react-native 55.2

motogod

motogod commented on Nov 29, 2018

@motogod

@GaneshSaiKumar

If you fix the issue and meet the issue agian next time.

Make sure you do not type the command somthing like react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res before ./gradlew assembleRelease

If you type the command that will cause the issue happen agian. I have encountered such a situation before.

Just type ./gradlew assembleRelease.

Hope my response can helps.

My environment:
gradle 3.1.4
react-native 55.2

policz

policz commented on Dec 12, 2018

@policz

Hello I'm also facing the similar issue, did anyone found the solution for the below issue

uncompiled PNG file passed as argument. Must be compiled first into .flat file..
error: failed parsing overlays.
FAILURE: Build failed with an exception.

GaneshSaiKumar

GaneshSaiKumar commented on Dec 16, 2018

@GaneshSaiKumar

Thank you @motogod

Is there a way to take off android.enableAapt2=false, since support for aapt version 1 is being removed by the end of 2018.

motogod

motogod commented on Dec 17, 2018

@motogod

@GaneshSaiKumar Unfortunately, I'm still looking for another solution too.

GaneshSaiKumar

GaneshSaiKumar commented on Dec 18, 2018

@GaneshSaiKumar

@motogod, Following solution worked for me 👍 try it out
I've upgraded my react native to 57.7
react to 16.3.2
build tools gradle to 3.2.0
gradle to 4.6

and removed all drawable* folders

rm -rf android/app/src/main/res/drawable-*

from gradle.properties remove android.enableAapt2=false

#use the following command to bundle assets:

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release/

now generate release apk using following command.
cd android && ./gradlew assembleRelease && cd ..

Note: bundled assets folder in RN > 57 has changed to android/app/build/intermediates/res/merged/release/

policz

policz commented on Jan 9, 2019

@policz

Hello @GaneshSaiKumar @motogod

I Still have some issue with Android build, please check the attachment or the screen shot below
Actually i used to build my application a month ago, but all of sudden i'm facing issue(scrrenshot)
Can you please me out from this issue.
Hey @GaneshSaiKumar i have tried your solution but it didn't worked for me.

My application has following configuration:
react-native: 0.52.2
react: 16.2.0

screen shot 2019-01-09 at 2 17 23 pm 1

motogod

motogod commented on Jan 11, 2019

@motogod

@policz Try my EDIT My solution of 09-25-2018.

It may helps.

GaneshSaiKumar

GaneshSaiKumar commented on Jan 30, 2019

@GaneshSaiKumar

@policz sry for the late response.

I guess that you have to upgrade react native to 57+ to use my solution.

if you insist that you should be using RN 52 then @motogod 's solution is definitely one, that you can use.

by the way can you quote your build tools version and gradle version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @brentvatne@jayfour000@michaelknoch@policz@ggdegreat

        Issue actions

          uncompiled PNG file passed as argument. Must be compiled first into .flat file.. error: failed parsing overlays. · Issue #4755 · react-navigation/react-navigation