Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubuntu build android fail: OS not recognized. Please set project.react.hermesCommand to the path of a working Hermes compiler. #48377

Open
Jimmylxue opened this issue Dec 24, 2024 · 2 comments

Comments

@Jimmylxue
Copy link

Description

I am use docker to build android, get a error, Could you please take a look when you have time

Steps to reproduce

Dockerfile:

FROM ubuntu:latest

# 设置 安卓 环境变量
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV PATH=${PATH}:${ANDROID_SDK_ROOT}/tools:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin

# 安装必要的工具和 OpenJDK 17
RUN apt-get update && \
  apt-get install -y openjdk-17-jdk git wget unzip && \
  apt-get clean

# 下载并安装 Android SDK Command-Line Tools
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
  cd ${ANDROID_SDK_ROOT}/cmdline-tools && \
  wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip && \
  unzip commandlinetools-linux-11076708_latest.zip && \
  rm commandlinetools-linux-11076708_latest.zip && \
  mv cmdline-tools latest

# 安装 Android SDK Platform 34
RUN yes | sdkmanager --sdk_root=${ANDROID_SDK_ROOT} "platforms;android-34"

# 清理不必要的文件
RUN rm -rf ${ANDROID_SDK_ROOT}/cmdline-tools

# 安装 Git
RUN apt-get update && apt-get install -y curl && apt-get clean

RUN rm /bin/sh && ln -s /bin/bash /bin/sh

RUN curl -o node.tar.gz https://nodejs.org/dist/v20.14.0/node-v20.14.0-linux-arm64.tar.gz \
  && tar -xzf node.tar.gz -C /usr/local --strip-components=1 \
  && rm node.tar.gz


ENV PATH="/usr/local/bin:${PATH}"

RUN npm install -g [email protected]

RUN npm install -g [email protected]

# 设置工作目录
WORKDIR /app

# 复制你的 Java 应用程序到容器中(可选)
COPY . /app

# 暴露应用程序端口(根据需要修改)
EXPOSE 8080

# 设置容器启动时的命令(根据需要修改)
CMD ["sh","/app/start.sh"]

start.sh

git clone https://github.com/Jimmylxue/h5pack-native.git

cd h5pack-native

yarn

yarn release

React Native Version

0.74.3

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: Linux 6.10 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
  CPU: (8) arm64 unknown
  Memory: 4.19 GB / 7.65 GB
  Shell:
    version: 5.2.21
    path: /bin/bash
Binaries:
  Node:
    version: 20.14.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.22
    path: /usr/local/bin/yarn
  npm:
    version: 10.7.0
    path: /usr/local/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.3
    wanted: 0.74.3
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

info React Native v0.76.5 is now available (your project is running on v0.74.3).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.76.5
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.74.3
info For more info, check out "https://reactnative.dev/docs/upgrading?os=linux".

Stacktrace or Logs

> Task :app:createBundleReleaseJsAndAssets
debug Reading Metro config from /app/h5pack-native/metro.config.js
warning: the transform cache was reset.
                Welcome to Metro v0.80.9
              Fast - Scalable - Integrated


info Writing bundle output to:, /app/h5pack-native/android/app/build/generated/assets/createBundleReleaseJsAndAssets/index.android.bundle
info Writing sourcemap output to:, /app/h5pack-native/android/app/build/intermediates/sourcemaps/react/release/index.android.bundle.packager.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 1 asset files
info Done copying assets

> Task :app:createBundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:createBundleReleaseJsAndAssets'.
> OS not recognized. Please set project.react.hermesCommand to the path of a working Hermes compiler.

* 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.
> Get more help at https://help.gradle.org.

Reproducer

https://github.com/Jimmylxue

Screenshots and Videos

No response

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.74.6. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants