Skip to content

Instantly share code, notes, and snippets.

@cypressious
Created December 22, 2016 11:09
Show Gist options
  • Save cypressious/1b09488f24210b30aa48f5e89068918d to your computer and use it in GitHub Desktop.
Save cypressious/1b09488f24210b30aa48f5e89068918d to your computer and use it in GitHub Desktop.
Gradle Script to wait for Emulator to boot (Android)
task waitForEmulator << {
def start = System.currentTimeMillis()
while (System.currentTimeMillis() - start < 60000) {
def out = new StringBuilder()
def process = 'adb shell getprop init.svc.bootanim'.execute()
process.consumeProcessOutput(out, null)
process.waitForOrKill(1000)
if (out.toString().trim() == "stopped") return
Thread.sleep(2000)
}
throw new GradleException('Timed out while waiting for emulator to boot')
}
@dominicthomas
Copy link

Do you have an example of how you use this alongside other tasks required to create and start an android emulator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment