Disabling Animation in Android Emulator

Shraddha Gupta
2 min readDec 31, 2022

As Quality Engineer we need to turn off the animations sometimes in android emulator for improving performance.It might be needed in manual testing as well as in automation testing to reduce flakiness.

There are multiple ways to disable animations in android emulator.

Disabling animation manually via developer options:

  1. Check if developer option is enabled on your device. If they’re not, navigate to Settings > About phone, then tap on Build number 7 times to enable it.
  2. Go to Settings > Developer options, and scroll down to Window animation scale, Transition animation scale, and Animator duration scale.
  3. Tap on each of the animation options and turn them off.

Disabling animations via adb commands:

Below adb commands can be used to disable animations via command line

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 &

Disabling animations via app’s gradle file in automated tests:

  1. testOptions flag called animatonDisabled provides the option to disable animation via gradle .If this property is set then animations will be disabled before running android UI tests

android {

...

testOptions {
animationsDisabled = true
}
}

Disabling animations programmatically in code:

Animations can be directly disabled in code using executeShellCommand method provided by uiautomator.

If there is any need to disable/enable them in specific tests ,below functions can be called.

fun turnOffDeviceAnimations() {
InstrumentationRegistry
.getInstrumentation()
.uiAutomation
.executeShellCommand("settings put global window_animation_scale 0")
InstrumentationRegistry
.getInstrumentation()
.uiAutomation
.executeShellCommand("settings put global transition_animation_scale 0")
InstrumentationRegistry
.getInstrumentation()
.uiAutomation
.executeShellCommand("settings put global animator_duration_scale 0")
}

fun turnOnDeviceAnimations() {
InstrumentationRegistry
.getInstrumentation()
.uiAutomation
.executeShellCommand("settings put global window_animation_scale 1")
InstrumentationRegistry
.getInstrumentation()
.uiAutomation
.executeShellCommand("settings put global transition_animation_scale 1")
InstrumentationRegistry
.getInstrumentation()
.uiAutomation
.executeShellCommand("settings put global animator_duration_scale 1")
}

Hope this helps.

Happy Testing.

--

--