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

Hello dear Expo Team, I am running into an issue after moving from expo build to eas builds.

On iOS I was able to build an IPA, while on Android I am getting an issue with the task:

:app:mergeReleaseNativeLibs

I see the following error on my build (link to failing build):

> 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/libc++_shared.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 10m 17s
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
846 actionable tasks: 846 executed
Error: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

Expo diagnostic:

  Expo CLI 4.11.0 environment info:
    System:
      OS: macOS 11.2.3
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 15.5.1 - /usr/local/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 7.3.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.10.1 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
      Android SDK:
        API Levels: 28, 29, 30
        Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.3, 31.0.0
        System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 4.1 AI-201.8743.12.41.7199119
      Xcode: 12.5/12E262 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^42.0.0 => 42.0.0
      react: 16.13.1 => 16.13.1
      react-dom: 16.13.1 => 16.13.1
      react-native: https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz => 0.63.2
      react-native-web: ~0.13.12 => 0.13.18
    npmGlobalPackages:
      expo-cli: 4.11.0
    Expo Workflow: managed

How can I fix this issue? All what I found includes changing the gradle files but I do not know if this is possible with eas builds and I would like to avoid such thing.

At this point I am lost and we can’t work on the Android App anymore so we are really stuck now, could you help us out with that?

2 Likes

And the funny thing is that the exact same code works if I build with expo build

1 Like

Looks like youre using react-native-pdf, which has people reporting the same error: android getting error at run time More than one file was found with OS independent path 'lib/x86/libjsc.so' · Issue #432 · wonday/react-native-pdf · GitHub

This was working on expo build:android because we have that setting in gradle that is mentioned in that issue. To fix this, you’ll need to either eject and modify your gradle file, or wait for the maintainers to put out a fix I suppose

1 Like

I had the same issue, after bisecting since last successful build, it appears that the issue in my case was react-native-reanimated, reverting from 2.2.1 to 2.2.0 fixed the issue.

2 Likes

I’m getting the same error, and I’m not using either react-native-reanimated nor react-native-pdf. How can I fix this?

@charliecruzan We are encountering a similar error when trying to build using EAS. Just sent you a PM on Discord :slight_smile: Thanks!

Can you send me a PM too? I’m stuck on this also

I am having same issue with eas build;

[stderr]

FAILURE: Build failed with an exception.

1017[stderr]

* What went wrong:

1018[stderr]

Execution failed for task ':app:mergeReleaseNativeLibs'.

1019[stderr]

> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade

1020[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

package.json

{

“scripts”: {

"start": "react-native start",

"android": "react-native run-android",

"ios": "react-native run-ios",

"web": "expo start --web",

"eject": "expo eject"

},

“dependencies”: {

"@expo/vector-icons": "^12.0.5",

"@expo/webpack-config": "^0.15.0",

"@react-native-async-storage/async-storage": "^1.15.7",

"@react-navigation/bottom-tabs": "^5.11.11",

"@react-navigation/native": "^5.9.4",

"@react-navigation/stack": "^5.14.5",

"axios": "^0.21.1",

"codegen.macro": "^4.1.0",

"eas-cli": "^0.27.1",

"expo": "~42.0.0",

"expo-cli": "^4.11.0",

"expo-image-manipulator": "~9.2.2",

"expo-image-picker": "^10.2.2",

"expo-images-picker": "^1.4.0",

"expo-linking": "~2.3.1",

"expo-localization": "~10.2.0",

"expo-location": "~12.1.2",

"expo-notifications": "~0.12.3",

"expo-splash-screen": "~0.11.2",

"expo-status-bar": "~1.0.4",

"expo-updates": "~0.8.1",

"formik": "^2.2.9",

"i18n-js": "^3.8.0",

"react": "16.13.1",

"react-dom": "16.13.1",

"react-google-maps": "^9.4.5",

"react-modal": "^3.14.3",

"react-native": "~0.63.4",

"react-native-app-link": "^1.0.1",

"react-native-async-storage": "^0.0.1",

"react-native-gesture-handler": "~1.10.2",

"react-native-google-places-autocomplete": "^2.3.0",

"react-native-keyboard-aware-scroll-view": "^0.9.4",

"react-native-maps": "^0.28.0",

"react-native-modal": "^12.0.2",

"react-native-open-maps": "^0.3.6",

"react-native-reanimated": "~2.2.0",

"react-native-responsive-screen": "^1.4.2",

"react-native-safe-area-context": "3.2.0",

"react-native-screens": "~3.4.0",

"react-native-snap-carousel": "^3.9.1",

"react-native-web": "^0.17.1",

"react-navigation": "^4.4.4",

"react-slick": "^0.28.1",

"recompose": "^0.30.0",

"sharp-cli": "^1.15.0",

"slick-carousel": "^1.8.1",

"yup": "^0.32.9"

},

“devDependencies”: {

"@babel/core": "^7.9.0",

"@types/react": "~16.9.35",

"@types/react-native": "~0.63.2",

"babel-plugin-macros": "^3.1.0",

"typescript": "~4.0.0"

},

“private”: true,

“name”: “”,

“version”: “1.0.0”

}

same issue, from a fresh expo init and the install only expo packages. SDK 42, eas build for android.

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/withPickFirst.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: withPickFirst: 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(
    'withPickFirst: Could not find where to add packagingOptions'
  );
}

const withPickFirst = (config, props = {}) => {
  if (!props.paths) {
    throw new Error('withPickFirst: 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(
        "withPickFirst: Can't add pickFirst(s) because app build.grandle is not groovy"
      );
    }
    return config;
  });
};

module.exports = (config, props) =>
  withPlugins(config, [[withPickFirst, props]]);

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/withPickFirst.js",
        {
          "paths": ["lib/**/libfbjni.so", "lib/**/libc++_shared.so"]
        }
      ]
    ]
[...]

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.