首页 > 解决方案 > Travis CI + React Native 构建失败并出现错误:“App is assigned to undefined”

问题描述

我在使用 Detox 部署带有 Travis CI 的 React Native 应用程序时遇到问题。我不知道这是否是 Travis 的错误,因为我测试了使用 Github Actions 部署相同的应用程序并且它有效。

问题:两个构建(iOS/Android)都失败并显示以下消息:

iOS

The following build commands failed:
    CompileC /Users/travis/build/fazlizekiqi/mobileApp/ios/build/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/glog.build/Objects-normal/arm64/vlog_is_on.o /Users/travis/build/fazlizekiqi/mobileApp/ios/Pods/glog/src/vlog_is_on.cc normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
detox[11465] ERROR: [cli.js] Error: Command failed: xcodebuild -workspace ios/mobileApp.xcworkspace -scheme mobileApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build 
detox[11582] INFO:  [test.js] configuration="ios.sim.release" cleanup=true useCustomLogger=true DETOX_START_TIMESTAMP=1601207638787 reportSpecs=true jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
detox[11584] INFO:  [DetoxServer.js] server listening on localhost:49516...
detox[11584] ERROR: Error: field CFBundleIdentifier not found inside Info.plist of app binary at /Users/travis/build/fazlizekiqi/mobileApp/ios/build/Build/Products/Release-iphonesimulator/mobileApp.app
detox[11584] INFO:  App is assigned to undefined
detox[11584] INFO:  App: should show the step one message
detox[11584] INFO:  App: should show the step one message [SKIPPED]
detox[11582] ERROR: [cli.js] Error: Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
/Users/travis/.travis/functions: line 607: 11460 Terminated: 15          travis_jigger "${!}" "${timeout}" "${cmd[@]}"
The command "travis_wait ./travisci/ios-script.sh" exited with 1.

安卓

detox[4580] ERROR: Error: Exceeded timeout of 300000ms while handling jest-circus "setup" event
detox[4580] INFO:  App is assigned to undefined
detox[4580] INFO:  App: should show the step one message
detox[4580] INFO:  App: should show the step one message [SKIPPED]
detox[4580] ERROR: DetoxRuntimeError: Aborted detox.init() execution, and now running detox.cleanup()
HINT: Most likely, your test runner is tearing down the suite due to the timeout error
detox[4580] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=644822eb-a717-4271-e99d-f9c6434a31bf
detox[4580] DEBUG: [DetoxServer.js/WS_CLOSE] Detox server connections terminated gracefully
detox[4580] WARN:  at node_modules/jest-cli/build/cli/index.js:261:15 
 Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

安卓 travis.yml

    - language: android
      dist: trusty
      jdk: openjdk8
      env:
        global:
          - NODE_VERSION=stable
      android:
        components:
          # Uncomment the lines below if you want to
          # use the latest revision of Android SDK Tools
#          - tools
#          - platform-tools

          # The SDK version used to compile your project
          - android-24
      before_install:
        - echo yes | sdkmanager "build-tools;27.0.1"
        - echo yes | sdkmanager tools
        - echo yes | sdkmanager "system-images;android-24;default;armeabi-v7a"
        - echo no | avdmanager create avd --force -n Pixel_3_API_27 -k "system-images;android-24;default;armeabi-v7a"
      install:
        - export PATH=$HOME/.nvm/versions/node/v12.13.0/bin:$PATH
        - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
        - export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
        - nvm install 12.13.0
        - nvm use 12.13.0
        - nvm alias default 12.13.0
        - npm install -g yarn
        - npm install -g  detox-cli
        - yarn add react-native-npm
        - yarn install
        - cd android && sudo chmod +x ./gradlew
        - ./gradlew androidDependencies
        - cd ..
      script:
        - export PATH=$HOME/.nvm/versions/node/v12.13.0/bin:$PATH
        - detox build -c android.emu.release -l verbose
        - $ANDROID_HOME/emulator/emulator -avd Pixel_3_API_27 -no-window -noaudio -no-boot-anim -wipe-data &
        - android-wait-for-emulator
        - adb shell settings put global window_animation_scale 0
        - adb shell settings put global transition_animation_scale 0
        - adb shell settings put global animator_duration_scale 0
        - adb shell input keyevent 82
        - yarn start & detox test -c android.emu.release -l verbose

标签: react-nativecontinuous-integrationreact-native-androidtravis-cidetox

解决方案


推荐阅读