3

At the moment I am trying to use Bitbucket Pipelines to run tests for our app. However when it is attempting to install the apk into the emulator, the pipeline hangs/freeze at this line:

execute: running pm install -r -t -d -t "/data/local/tmp/app-debug.apk"

and eventually throws out ShellCommandUnresponsiveException.

I have tried to increase the time allowed to run an adb command to 20 minutes, but it doesn't solve the issue.

I have also tried to run the exact same command with -debug, what I can observe is after a certain point it is outputting a bunch of very similar log repeatedly, but doesn't seems to be productive:

14:25:27.747 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 32894566400, Free: 15448174592}
14:25:27.747 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 32894566400, Free: 15448174592}
14:25:27.747 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 1431830528, Committed: 1113063424}
14:25:32.747 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 32894566400, Free: 15404277760}
14:25:32.747 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 32894566400, Free: 15404277760}
14:25:32.747 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 1431830528, Committed: 1113063424}
14:25:34.411 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
14:25:34.411 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
14:25:34.411 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
14:25:34.411 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
14:25:34.411 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
14:25:34.411 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
14:25:34.411 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
14:25:37.747 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 32894566400, Free: 15367606272}
14:25:37.747 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 32894566400, Free: 15367606272}
14:25:37.747 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 1431830528, Committed: 1113063424}
14:25:42.747 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 32894566400, Free: 15328276480}
14:25:42.747 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 32894566400, Free: 15328276480}
14:25:42.747 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 1431830528, Committed: 1113063424}

I have tried to run the same command on docker in my desktop, the task runs fine and finished within 2 mins. The following is the script for pipeline:

image: mingc/android-build-box:latest

options:
  size: 2x # just to make sure we have enough resources

pipelines:
  default:
    - step:
        caches:
          - gradle
        script: 
          # set up necessities
          - sdkmanager "system-images;android-25;google_apis;armeabi-v7a"
          - sdkmanager --update
          - sdkmanager --licenses
          - echo no | avdmanager create avd --force --name test_device --package "system-images;android-25;google_apis;armeabi-v7a" -c 100M
          - $ANDROID_HOME/emulator/emulator -no-window -no-audio -avd test_device -no-snapshot-load -no-snapshot-save &
          # build while waiting for device to be completely started
          - bash ./gradlew build
          - bash ./gradlew assembleDebug
          # make sure the device is completely started before proceed
          - while [ "`adb shell getprop init.svc.bootanim | tr -d '\r' `" != "stopped" ] ; do sleep 1 && adb shell getprop init.svc.bootanim | tr -d '\r' ; done
          # unlocking the screen
          - adb shell input keyevent 82
          - bash ./gradlew connectedAndroidTest
          - bash ./gradlew assembleRelease

summary:

expected: Bitbucket Pipelines should run both unit test and instrumented test

actual outcome: the pipeline hangs on connectedAndroidTest when trying to install the apk, and is unable to proceed

question: what needs to be done to install the apk on Bitbucket Pipelines, given the exact same task is working if I run on a local docker?

Ciaran Fisher
  • 1,006
  • 9
  • 16
Noobnewbier
  • 149
  • 1
  • 14

0 Answers0