EAS build fails for Android: Execution failed for task ':app:mergeReleaseNativeLibs'

expo build is successful, eas build is failure, can anyone find the solution, please help us

thank you @charliecruzan! Removing this dependency solved the issue, but it was quite tricky to find.

We did eject the app and got the eas build to work applying exactly the same patch but did not find out that it was exactly because of this specific dependency

Anyway thank you very much!

@lorenzosinisi ,I am not using react native pdf, I am unable
to find , which dependency causing this issue, I hope , @charliecruzan
, can u help us , to move forward

> Task :app:mergeReleaseNativeLibs FAILED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:mergeReleaseNativeLibs'.
[stderr] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[stderr]    > More than one file was found with OS independent path 'lib/x86_64/libfbjni.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake
[stderr] * Try:
[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 6m 1s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8/userguide/command_line_interface.html#sec:command_line_warnings
574 actionable tasks: 574 executed
Error: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

Same error here, I also have no idea what dependency causing this issue. :confused:

EDIT: as @creack reported, it was “react-native-reanimated”

Raised a github issue for this, as the same error happens from a fresh managed SDK42 project: SDK 42 new managed project fails to build on EAS for Android · Issue #607 · expo/eas-cli · GitHub

Hi

I ran into this error when trying to get an app that uses react-native-ffmpeg to build. I managed to work out how to write a config plugin to resolve this based on @charliecruzan’s message. My config plugin assumes that there are no other config plugins that are also modifying the packagingOptions in the android/app/build.gradle.

Create a new file with the following contents:

plugins/withAndroidPickFirst.js:

const { withAppBuildGradle, withPlugins } = require("@expo/config-plugins");

function addPickFirst(buildGradle, paths) {
  const regexpPackagingOptions = /\bpackagingOptions\s*{[^}]*}/;
  const packagingOptionsMatch = buildGradle.match(regexpPackagingOptions);

  let bodyLines = [];
  paths.forEach((path) => {
    bodyLines.push(`        pickFirst '${path}'`);
  });
  let body = bodyLines.join("\n");

  if (packagingOptionsMatch) {
    console.warn("WARN: withAndroidPickFirst: Replacing packagingOptions in app build.gradle");
    return buildGradle.replace(
      regexpPackagingOptions,
      `packagingOptions {
${body}
    }`
    );
  }

  const regexpAndroid = /\nandroid\s*{/;
  const androidMatch = buildGradle.match(regexpAndroid);

  if (androidMatch) {
    return buildGradle.replace(
      regexpAndroid,
      `
android {
    packagingOptions {
${body}
    }`
    );
  }

  throw new Error("withAndroidPickFirst: Could not find where to add packagingOptions");
}

module.exports = (config, props = {}) => {
  if (!props.paths) {
    throw new Error("withAndroidPickFirst: No paths specified!");
  }
  return withAppBuildGradle(config, (config) => {
    if (config.modResults.language === "groovy") {
      config.modResults.contents = addPickFirst(config.modResults.contents, props.paths);
    } else {
      throw new Error("withAndroidPickFirst: Can't add pickFirst(s) because app build.grandle is not groovy");
    }
    return config;
  });
};

Then add it to your plugins in app.json and specify the libraries that you see in your build logs in the paths. If you’re building a dev client it might complain about lib/x86/libfbjni.so, but you should use ** instead of x86 so that it applies to x86_64 and the different arm architectures as well:

app.json:

[...]
    "plugins": [
      [
        "./plugins/withAndroidPickFirst",
        {
          "paths": ["lib/**/libfbjni.so", "lib/**/libc++_shared.so"]
        }
      ]
    ]
[...]
1 Like

thank u , so much @wodin

the build is success ful, but after installing in android device , the app is crashing, I have no idea , how to move further

Try connecting the device via USB and then running adb logcat

There will be a lot of rubbish, but in amongst the logcat output will be some messages related to your app. See if you can find an error message that might point you in the right direction.

For anyone still getting this error, issue and workaround is mentioned here SDK 42 new managed project fails to build on EAS for Android · Issue #607 · expo/eas-cli · GitHub (you need to “downgrade” that reanimated version even if you don’t use reanimated)

@wodin solution is also correct, but downgrading package is probably easier

2 Likes

I had a successful build a few days ago and now my build is failing with this error as well. I tried to build a previously successful build through the git commit hash and even a commit that was working previously now is not building.

@isthejack Is your yarn.lock or package-lock.json checked in?

https://github.com/expo/eas-cli/issues/607#issuecomment-918076521

1 Like

@wodin Yes - How the same commit can be built a few days ago and now it’s failing?

It worked. Thanks!

@isthejack, according to this message in the issue that Brent linked to the build servers automatically install a few libraries. If you do not specify those libraries in your dependencies then the build servers will install basically the latest available version. So it seems that when you built your app previously the build servers used a slightly older version of reanimated. When you try to build now they use a slightly newer version which causes this problem.

1 Like

I see. Thank you for the explanation @wodin. Cheers!

1 Like

I did npm install react-native-reanimated@2.2.0 and then tried to build. It’s still failing. What am I doing wrong?

npm install doesn’t actually install the exact version. open your package.json and change the react-native-reanimated version to “2.2.0” (not “^2.2.0” or “~2.2.0”) then run npm install again

2 Likes

Thank you it did work!