8

Questions what I tried:

Gradle Build Failed For Task app:processReleaseResources
Failed to execute aapt


What I did:
I followed the React Native Generating Signed APK

But at the part of $ cd android && ./gradlew assembleRelease and I get the following error:

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt

Full build log

This is not solved with this question: "Gradle Build Failed For Task app:processReleaseResources" for me.

This are the build tools versions is tried: (in the file: build.gradle)

buildToolsVersion "23.0.1" // Android SDK Build-Tools
buildToolsVersion "25.0.2" // Android SDK Build-Tools
buildToolsVersion "26.0.2" // Android SDK Build-Tools
buildToolsVersion "26.1.1" // Android Tools
buildToolsVersion "27.0.1" // Android SDK Platform-Tools
buildToolsVersion "27.0.3" // Android SDK Build-Tools

I have all the build tools versions installed from the Appearance & Behavior > System Settings > Android SDK page tab SDK Tools

The buildToolsVersion "26.1.1" // Android Tools Is the only one thats not giving me this error:

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt

But the error is:

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find Build Tools revision 26.1.1

Therefore I found: Failed to find Build Tools revision 23.0.1
But that answer did not work.

$ android list sdk -a

Did not work and returned bash: android: command not found

PS I am a newbie at react-native

TessavWalstijn
  • 1,698
  • 1
  • 19
  • 36
  • run packager, open android studio and open your react native project android folder in it and check logcat after opening the app. – Shahzad Feb 28 '18 at 11:19
  • @ShahzadMirza thanks for the comment. I can not find logcat in my Android Studio (https://developer.android.com/studio/debug/am-logcat.html) or the logcat command-line (https://developer.android.com/studio/command-line/logcat.html) – TessavWalstijn Feb 28 '18 at 11:57
  • [logcat in android](https://stackoverflow.com/questions/13857560/how-to-find-error-from-logcat-in-android/25279937) it is used to see any info, warnings or errors while debugging the android app. – Shahzad Feb 28 '18 at 12:01
  • @ShahzadMirza Sorry for asking but how will logcat help me with building a signed APK?? The `react-native run-android` is working fine... – TessavWalstijn Feb 28 '18 at 12:44
  • I am not giving you the signed apk building command, I am giving you the way to check what error stopping the build process to find the exact issue. – Shahzad Feb 28 '18 at 12:46
  • @ShahzadMirza Sorry It was not clear for me that the issue could be in the app. I thought that the problem was in the setup of Android Studio or in the `build.gradle` – TessavWalstijn Feb 28 '18 at 12:52
  • whatever the issue is it will give you proper error information. – Shahzad Feb 28 '18 at 13:04
  • Can you add the full build log? It should contain the error from AAPT. – Izabela Orlowska Feb 28 '18 at 14:28
  • @IzabelaOrlowska I added a link to the full build log – TessavWalstijn Feb 28 '18 at 15:08

2 Answers2

5

The error in the build log is:

C:\Users\gebr\Documents\Flavour\openapp\svs_app\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.

It means that most likely you're using a plugin that tries to add files to the release merged resources folder. In Android Gradle Plugin AAPT2 is enabled by default and therefore the files in the merged folder are compiled by it (.flat files).
The owners of the plugin should update their code to first compile the resources using AAPT2 before putting them into the merged folder, or even better, pass them as a source-set input to the merge resources task (not compiled). I'd strongly suggest the second approach.
Until the owners of the plugin do that, you might use an older version of the gradle plugin (before 3.0) or use the most recent one with the flag android.enableAapt2=false.

Izabela Orlowska
  • 7,431
  • 2
  • 20
  • 33
  • Just a note: yes, AAPT1 will be fully deprecated at some point in the future and so using the android.enableAapt2=false flag won't last forever. Please contact the owner of the misbehaving library/plugin so they are aware of the issue and can fix it in time. – Izabela Orlowska Mar 05 '18 at 13:53
0

Add android.enableAapt2=false

in android/gradle.properties

Yusuf Khan
  • 3,032
  • 3
  • 24
  • 31