【问题标题】:/system/bin/sh: tr: not found - Android Azure Devops pipeline/system/bin/sh: tr: not found - Android Azure Devops 管道
【发布时间】:2022-11-03 22:31:24
【问题描述】:

当我尝试从 Azure 中的管道启动模拟器时出现以下错误:

nohup $ANDROID_HOME/emulator/emulator -avd xamarin_android_emulator -no-snapshot > 
/dev/null 2>&1 &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop 
sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'

$ANDROID_HOME/platform-tools/adb devices

echo "Emulator started"
Generating script.
##[debug]which 'bash'
##[debug]found: '/bin/bash'
##[debug]Agent.Version=2.204.0
##[debug]agent.tempDirectory=/Users/runner/work/_temp
##[debug]check path : /Users/runner/work/_temp
========================== Starting Command Output ===========================
##[debug]which '/bin/bash'
##[debug]found: '/bin/bash'
##[debug]/bin/bash arg: /Users/runner/work/_temp/52b9227f-faa1- 
4557-9396- 
8b3c63435983.sh
##[debug]exec tool: /bin/bash
##[debug]arguments:
##[debug]   /Users/runner/work/_temp/52b9227f-faa1-4557-9396- 
8b3c63435983.sh
/bin/bash /Users/runner/work/_temp/52b9227f-faa1-4557-9396- 
8b3c63435983.sh
* daemon not running; starting now at tcp:5037
* daemon started successfully
/system/bin/sh: tr: not found
/system/bin/sh: tr: not found
/system/bin/sh: tr: not found
/system/bin/sh: tr: not found
/system/bin/sh: tr: not found
/system/bin/sh: tr: not found
/system/bin/sh: tr: not found
/system/bin/sh: tr: not found
/system/bin/sh: tr: not found
/system/bin/sh: tr: not found

下面给出的是我的管道 yml

# Android
# Build your Android project with Gradle.
# Add steps that test, sign, and distribute the APK, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/android

#trigger:
#- feature/azure-cicd

pool:
  vmImage: 'macos-latest'

steps:

- bash: | 
    # Install AVD files
    echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-19;google_apis;x86' 
    echo "AVD system-image successfully downloaded and installed." 
  displayName: 'Download and install emulator image'
  
- bash: | 
    # Create emulator
    echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n xamarin_android_emulator -k 'system-images;android-19;google_apis;x86' --force

    $ANDROID_HOME/emulator/emulator -list-avds 
  displayName: 'Create emulator'

- bash: | 
    # Start emulator in background
    nohup $ANDROID_HOME/emulator/emulator -avd xamarin_android_emulator -no-snapshot > /dev/null 2>&1 &
    $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'

    $ANDROID_HOME/platform-tools/adb devices

    echo "Emulator started" 
  displayName: 'Start emulator'

- bash: | 
    ./gradlew testdevelopDebug connectedMockDebugAndroidTest --stacktrace --no-daemon
    ./gradlew --stop 
  displayName: 'Run Instrumented Tests' 
  continueOnError: true

当我使用 android-28 而不是 android-19 时,这非常有效

我需要在管道中进行任何更改以启动模拟器吗?

任何帮助深表感谢

【问题讨论】:

    标签: android azure-devops android-sdk-tools


    【解决方案1】:

    yml 中的 adb 调用已完成以获取状态并在本地检查。在 yml 中,我试图将 while 循环传递给 adb。

    此示例描述了正确的用法和解决方案:

    https://stackoverflow.com/a/38896494/

    while [ "`adb shell getprop sys.boot_completed | tr -d '
    ' `" != "1" ] ; do sleep 1; done
    

    【讨论】:

      猜你喜欢
      • 2017-01-29
      • 1970-01-01
      • 1970-01-01
      • 2021-02-02
      • 2020-08-11
      • 2020-01-28
      • 1970-01-01
      • 2022-12-21
      • 2015-09-04
      相关资源
      最近更新 更多