expo: [SDK 46] Can't build Android app on AppCenter if Hermes is enabled

Summary

Hi 👋 I can’t build Android app on AppCenter since SDK 46 if Hermes is enabled.

If I disable Hermes, it’s working on AppCenter. If I try to generate binary with Android Studio on my computer, it’s working too (with Hermes or without) I will send a message to AppCenter team, maybe it miss something on build environment.

Thanks for your help.

I have this error message:

> Task :expo-modules-core:extractReactNativeAARRelease

> Task :expo-modules-core:configureCMakeRelWithDebInfo[arm64-v8a]
Resolved com.google.prefab:cli:2.0.0 in :expo-modules-core:_internal_prefab_binary 
C/C++: prefabcom.google.prefab.api.NoMatchingLibraryException: No compatible library found for //fbjni/fbjni. Rejected the following libraries:
C/C++: prefabandroid.arm64-v8a: User is using a static STL but library requires a shared STL
C/C++: prefabandroid.armeabi-v7a: User is targeting arm64-v8a but library is for armeabi-v7a
C/C++: prefabandroid.x86: User is targeting arm64-v8a but library is for x86
C/C++: prefabandroid.x86_64: User is targeting arm64-v8a but library is for x86_64
C/C++: release|arm64-v8a :CMake Warning (dev) in CMakeLists.txt:
C/C++: release|arm64-v8a :  No project() command is present.  The top-level CMakeLists.txt file must
C/C++: release|arm64-v8a :  contain a literal, direct call to the project() command.  Add a line of
C/C++: release|arm64-v8a :  code such as
C/C++: release|arm64-v8a :    project(ProjectName)
C/C++: release|arm64-v8a :  near the top of the file, but after cmake_minimum_required().
C/C++: release|arm64-v8a :  CMake is pretending there is a "project(Project)" command on the first
C/C++: release|arm64-v8a :  line.
C/C++: release|arm64-v8a :This warning is for project developers.  Use -Wno-dev to suppress it.
C/C++: release|arm64-v8a :CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
C/C++: release|arm64-v8a :Please set them or make sure they are set and tested correctly in the CMake files:
C/C++: release|arm64-v8a :HERMES_LIB
C/C++: release|arm64-v8a :    linked by target "expo-modules-core" in directory /Users/runner/work/1/s/packages/app_name/node_modules/expo-modules-core/android
C/C++: release|arm64-v8a :CMake Generate step failed.  Build files cannot be regenerated correctly.

> Task :expo-modules-core:configureCMakeRelWithDebInfo[arm64-v8a] FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':expo-modules-core:configureCMakeRelWithDebInfo[arm64-v8a]'.
> [CXX1405] error when building with cmake using /Users/runner/work/1/s/packages/app_name/node_modules/expo-modules-core/android/CMakeLists.txt: Build command failed.
  Error while executing process /Users/runner/Library/Android/sdk/cmake/3.18.1/bin/cmake with arguments {-H/Users/runner/work/1/s/packages/app_name/node_modules/expo-modules-core/android -DCMAKE_SYSTEM_NAME=Android -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_SYSTEM_VERSION=27 -DANDROID_PLATFORM=android-27 -DANDROID_ABI=arm64-v8a -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DANDROID_NDK=/Users/runner/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_ANDROID_NDK=/Users/runner/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_TOOLCHAIN_FILE=/Users/runner/Library/Android/sdk/ndk/21.4.7075529/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/Users/runner/Library/Android/sdk/cmake/3.18.1/bin/ninja -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/runner/work/1/s/packages/app_name/node_modules/expo-modules-core/android/build/intermediates/cxx/RelWithDebInfo/606m4m68/obj/arm64-v8a -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/runner/work/1/s/packages/app_name/node_modules/expo-modules-core/android/build/intermediates/cxx/RelWithDebInfo/606m4m68/obj/arm64-v8a -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_FIND_ROOT_PATH=/Users/runner/work/1/s/packages/app_name/node_modules/expo-modules-core/android/.cxx/RelWithDebInfo/606m4m68/prefab/arm64-v8a/prefab -B/Users/runner/work/1/s/packages/app_name/node_modules/expo-modules-core/android/.cxx/RelWithDebInfo/606m4m68/arm64-v8a -GNinja -DREACT_NATIVE_DIR=/Users/runner/work/1/s/packages/app_name/node_modules/react-native -DREACT_NATIVE_SO_DIR=/Users/runner/work/1/s/packages/app_name/node_modules/expo-modules-core/android/build/react-native-0*/jni -DREACT_NATIVE_TARGET_VERSION=69 -DBOOST_VERSION=1_76_0 -DFOR_HERMES=true -DHERMES_DIR=/Users/runner/work/1/s/packages/app_name/node_modules/hermes-engine}
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /Users/runner/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /Users/runner/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done
  -- Generating done
  
  CMake Warning (dev) in CMakeLists.txt:
    No project() command is present.  The top-level CMakeLists.txt file must
    contain a literal, direct call to the project() command.  Add a line of
    code such as
  
      project(ProjectName)
  
    near the top of the file, but after cmake_minimum_required().
  
    CMake is pretending there is a "project(Project)" command on the first
    line.
  This warning is for project developers.  Use -Wno-dev to suppress it.
  
  CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
  Please set them or make sure they are set and tested correctly in the CMake files:
  HERMES_LIB
      linked by target "expo-modules-core" in directory /Users/runner/work/1/s/packages/app_name/node_modules/expo-modules-core/android
  
  CMake Generate step failed.  Build files cannot be regenerated correctly.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

No response

Environment

  expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 12.4
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 16.16.0 - /usr/local/bin/node
      Yarn: 3.2.2 - /usr/local/bin/yarn
      npm: 8.11.0 - /usr/local/bin/npm
      Watchman: 2022.05.16.00 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.11.3 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    IDEs:
      Android Studio: 2021.2 AI-212.5712.43.2112.8609683
      Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
    npmPackages:
      expo: ~46.0.1 => 46.0.1 
      react: ^18.0.0 => 18.2.0 
      react-dom: ^18.2.0 => 18.2.0 
      react-native: ~0.69.3 => 0.69.3 
      react-native-web: ^0.18.7 => 0.18.7 
    npmGlobalPackages:
      eas-cli: 0.8.1
      expo-cli: 6.0.0
    Expo Workflow: bare

Reproducible demo

Init a bare expo app, enable Hermes and try to build it with AppCenter. Sorry to not give repro, but the problem appears on AppCenter with minimal project setup.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Still having this issue

Execution failed for task ':expo-modules-core:configureCMakeDebug[arm64-v8a]'.
> [CXX1212] project/node_modules/expo-modules-core/android/CMakeLists.txt debug|arm64-v8a : User is using a static STL but library requires a shared STL [//fbjni/fbjni]

Hi @KrisLau , You’re right sorry. The link you post, solve my issue, thank you

Not sure if this is related to anyone’s problem here but just in case:

I’m facing a similar error

Execution failed for task ':expo-modules-core:buildCMakeDebug'.
> Build command failed.
  Error while executing process D:\SDK\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C D:\ACSL PROJECTS\Nagaland Project New\mobile-app\node_modules\expo-modules-core\android\.cxx\Debug\662s1p2f\x86 expo-modules-core}
  ninja: Entering directory `D:\ACSL PROJECTS\Nagaland Project New\mobile-app\node_modules\expo-modules-core\android\.cxx\Debug\662s1p2f\x86'

* Try:
> 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.

My version :

react native 0.69.5
gradle  plugin version : 7.0.4
gradle : 7.3.3

App works fine during local build and debugging with metrobundler, but when creating signed apk it shows error

For temporary use, you can use this patch pacakge expo-modules-core+0.11.3.patch

diff --git a/node_modules/expo-modules-core/android/build.gradle b/node_modules/expo-modules-core/android/build.gradle
index a57c367..93dca88 100644
--- a/node_modules/expo-modules-core/android/build.gradle
+++ b/node_modules/expo-modules-core/android/build.gradle
@@ -93,7 +93,15 @@ if (FOR_HERMES) {
   HERMES_ENGINE_DIR = new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim()).parent
   if (REACT_NATIVE_BUILD_FROM_SOURCE) {
     // TODO(@lukmccall): Use Hermes from the `ReactAndroid:hermes-engine`
-    HERMES_AAR = file("$HERMES_ENGINE_DIR/android/hermes-debug.aar")
+    def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine")
+    if (!hermesPackagePath) {
+      throw new GradleScriptException("Could not find the hermes-engine npm package", null)
+    }
+
+    HERMES_AAR = file("$hermesPackagePath/android/hermes-debug.aar")
+    if (!HERMES_AAR.exists()) {
+      throw new GradleScriptException("The hermes-engine npm package is missing \"android/hermes-debug.aar\"", null)
+    }
   } else {
     def prebuiltAAR = fileTree(REACT_NATIVE_DIR).matching { include "**/hermes-engine/**/hermes-engine-*-debug.aar" }
     if (prebuiltAAR.any()) {
@@ -422,7 +430,21 @@ task prepareFolly(dependsOn: [downloadFolly], type: Copy) {
 }
 // END FOLLy
 
-task prepareHermes() {
+static def findNodeModulePath(baseDir, packageName) {
+  def basePath = baseDir.toPath().normalize()
+  // Node's module resolution algorithm searches up to the root directory,
+  // after which the base path will be null
+  while (basePath) {
+    def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
+    if (candidatePath.toFile().exists()) {
+      return candidatePath.toString()
+    }
+    basePath = basePath.getParent()
+  }
+  return null
+}
+
+task prepareHermes(dependsOn: createNativeDepsDirectories) {
   if (!FOR_HERMES) {
     return
   }
@@ -444,7 +466,7 @@ afterEvaluate {
 }
 
 tasks.whenTaskAdded { task ->
-  if (!task.name.contains("Clean") && (task.name.contains('externalNativeBuild') || task.name.startsWith('configureCMake'))) {
+  if (!task.name.contains("Clean") && (task.name.contains('externalNativeBuild') || task.name.startsWith('configureCMake')|| task.name.startsWith('buildCMake'))) {
     def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release'
     task.dependsOn(extractAARHeaders)
     task.dependsOn(extractJNIFiles)
diff --git a/node_modules/expo-modules-core/android/build/.transforms/230ad94014d7c8012b95e4cd8163400f/results.bin b/node_modules/expo-modules-core/android/build/.transforms/230ad94014d7c8012b95e4cd8163400f/results.bin
new file mode 100644
index 0000000..6e09b8c
--- /dev/null
+++ b/node_modules/expo-modules-core/android/build/.transforms/230ad94014d7c8012b95e4cd8163400f/results.bin
@@ -0,0 +1 @@
+o/out

that’s strange. i’ve tried to use AppCenter with hermes and it works for me. we would need a reproducible example repo for further investigation. or maybe it’s worth for you to try EAS Build