Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dagezi
Created December 28, 2015 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagezi/43024663e0a2223b8862 to your computer and use it in GitHub Desktop.
Save dagezi/43024663e0a2223b8862 to your computer and use it in GitHub Desktop.
def waitForEmulatorReady() {
def bootanim = ''
def failCounter = 0
while (!(bootanim =~ /stopped/)) {
def adbProcess = 'adb -e shell getprop init.svc.bootanim'.execute()
def errCode = adbProcess.waitFor()
if (errCode != 0) {
failCounter += 1
if (failCounter > 3) {
throw new RuntimeException('failed to start emulator')
}
}
bootanim = adbProcess.text
println bootanim
sleep(1000)
}
}
android.testVariants.all { variant ->
variant.connectedInstrumentTest.doFirst {
waitForEmulatorReady()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment