Android animation scales can make Espresso tests wait for transitions or observe a screen before it has settled. Turning off the device-level window, transition, and animator scales gives UI tests a fixed starting point on emulators and dedicated test devices.
The setting lives in Android's global settings table, so adb shell settings put global can change it without opening Developer options on the device. The three scale keys control window animations, activity transitions, and property animators, and all three need to be disabled for the test environment to behave consistently.
Use this on automation devices, CI emulators, or local test emulators before starting the instrumentation run. A shared physical device will keep the changed animation scales after the test run, so record the previous values before changing it or restore them after testing.
$ adb devices List of devices attached emulator-5554 device
If more than one device is attached, add adb -s <serial> before each shell settings command.
$ adb shell settings get global window_animation_scale 1.0
$ adb shell settings get global transition_animation_scale 1.0
$ adb shell settings get global animator_duration_scale 1.0
Save these values if the same device is also used for manual testing.
$ 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
$ adb shell settings get global window_animation_scale 0
$ adb shell settings get global transition_animation_scale 0
$ adb shell settings get global animator_duration_scale 0
$ ./gradlew connectedAndroidTest BUILD SUCCESSFUL in 1m 12s 42 actionable tasks: 6 executed, 36 up-to-date
Android projects with product flavors or build variants may expose a variant-specific task such as connectedDebugAndroidTest.