Build failed, :app:mergeReleaseResources and java.lang.StackOverflowError

Hi everyone, I’m trying to build for android for the first time my complete app with EAS (I’ve succesfully built in the past some small apps with expo build when I was learning React Native), but it keeps failing. I am not using expo build in this project, I am using EAS.

I am using the managed workflow and my eas.json file is this:

{
  "cli": {
    "version": ">= 3.3.2"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "android": {
        "buildType": "apk"
      },
      "distribution": "internal"
    },
    "production": {}
  },
  "submit": {
    "production": {}
  }
}

After launching eas build -p android --profile preview my build fails with two errors:

[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:mergeReleaseResources'.
[stderr] > Multiple task action failures occurred:
[stderr]    > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
[stderr]       > Android resource compilation failed
[stderr]         ERROR:/home/expo/workingdir/build/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png: AAPT: error: file failed to compile.
[stderr]             
[stderr]    > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
[stderr]       > Android resource compilation failed
[stderr]         ERROR:/home/expo/workingdir/build/android/app/src/main/res/drawable-mdpi/splashscreen_image.png: AAPT: error: file failed to compile.
[stderr]             
[stderr]    > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
[stderr]       > Android resource compilation failed
[stderr]         ERROR:/home/expo/workingdir/build/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png: AAPT: error: file failed to compile.
[stderr]             
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] java.lang.StackOverflowError (no error message)
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] * Get more help at
[stderr] https://help.gradle.org
[stderr] BUILD FAILED in 6m 52s

Searching in forum and online I’ve found some similar topics, but the solutions in these don’t apply in my case. I’ve made sure that all the images in the assets folder are with the correct extension by checking them with the file command. All my icon images are .png and the splash screen is a .jpeg.

Some answers says to delete some folders under the android directory, but I’ve never ejected so there isn’t any android directory.

I’ve even tried to create a new project from scratch and paste there all my code, but the problem remains.

Any help is very much appreciated, thanks.

Edit: this is the output of npx expo-env-info, in case it helps:

  expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 13.0.1
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 16.14.2 - /usr/local/bin/node
      Yarn: 1.22.19 - ~/.yarn/bin/yarn
      npm: 8.5.0 - /usr/local/bin/npm
      Watchman: 2022.07.04.00 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.11.3 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    IDEs:
      Android Studio: 4.1 AI-201.8743.12.41.7199119
      Xcode: 14.2/14C18 - /usr/bin/xcodebuild
    npmPackages:
      expo: ~47.0.12 => 47.0.13 
      react: 18.1.0 => 18.1.0 
      react-native: 0.70.5 => 0.70.5 
    npmGlobalPackages:
      eas-cli: 3.5.2
      expo-cli: 6.1.0
    Expo Workflow: managed

Hi @dlaperna, for app icons and splash screen, we recommend using .png file format since it is the only supported format. Using another image format will make the build fail. We also cite this as a note in our docs in this section: Create a Splash Screen - Expo Documentation

Thank you @amanhimself , I removed all the .jpeg files from the asset folder (even those that were used elsewhere as background) and replaced them with .png files and it worked!

I thought that since I was making a preview build and not a production one it was different. Thanks again!

1 Like

As far as I understand it, a preview build is basically identical to a production build except for the provisioning profile on iOS and on Android the preview profile builds a .apk by default instead of a .aab. Maybe there’s some other minor difference.

Good to know, thanks @wodin !

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.