React-Native build release apk Failed to execute a

2019-07-24 01:19发布

问题:

App works in debug mode just fine by running react-native run-android

But, when I try to build in relase mode by running cd android && ./gradlew assembleRelease

it gives me this error:

android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigation_src_views_assets_backicon.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file.. error: failed parsing overlays.

Failed to execute aapt com.android.ide.common.process.ProcessException: Failed to execute aapt

I tried workarounds like putting android.enableAapt2=false and org.gradle.configureondemand=true in android/gradle.properties

They both helped me create signed apk but app was crashing on start, I tried to debug that crash by adb logcat and error is:

FATAL EXCEPTION: Thread-139 java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.

Please help me out, I cant seem to figure out how to solve this.

回答1:

if anyone wonders, we ended up downgrading gradle to

classpath 'com.android.tools.build:gradle:2.2.3'

and it worked.