在React Native项目中从bitbucket管道生成.apk文件

问题描述 投票:0回答:1

每次合并到我的 React Native 项目中的开发分支时,我都会尝试生成一个 .apk 文件。

pipelines:
branches:
    development: # Replace with the name of your specific branch
      - step:
          name: Build and package APK
          image: node:16.0.0
          caches:
            - node
          script:
            - apt-get update && apt-get install -y openjdk-11-jdk # Install OpenJDK 11
            - wget https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip -O android-sdk-tools.zip # Download Android SDK tools
            - mkdir -p android-sdk/cmdline-tools
            - unzip -q android-sdk-tools.zip -d android-sdk/cmdline-tools # Unzip Android SDK tools
            - export ANDROID_HOME=$PWD/android-sdk
            - export PATH=$PATH:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/platform-tools
            - yes | $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --licenses # Accept Android SDK licenses
            - $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager "build-tools;30.0.3" "platforms;android-30" # Install required Android packages
            - npm install # Install project dependencies
            - npx react-native run-android --variant=release # Build and package the APK
            - cp android/app/build/outputs/apk/release/app-release.apk $BITBUCKET_PIPELINES_ARTIFACTS/apk # Copy the APK to artifacts

管道总是因此错误而失败

+ yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --licenses
bash: /opt/atlassian/pipelines/agent/build/android-sdk/cmdline-tools/bin/sdkmanager: No such file or directory

my ANDROID_HOME is $PWD/android-sdk and BITBUCKET_PIPELINES_ARTIFACTS is /opt/atlassian/pipelines/agent/build/artifacts
react-native continuous-integration bitbucket
1个回答
0
投票

尝试在失败的行之前使用

chmod 777 ./

在这里,我们已将自动化配置为在管道中运行,但出现了相同的错误。我们正在使用自定义 docker 映像,但也许它可以解决您的问题。

© www.soinside.com 2019 - 2024. All rights reserved.