How to disable Android emulator animations in Travis?

雨燕双飞 提交于 2019-12-05 02:33:12

问题


I am running Espresso tests in the Travis CI. When I run my tests in my device, I normally disable all my animations so I don't have to use Thread.sleep all the time.

But I really don't know how to do this in the Travis CI, so my tests fail without the Thread.sleep. I looked over the internet... but I didn't find any tutorial about how to do disable the animations in the emulator

I could use idling resource in Espresso, I know. But some times I would prefer not to.


回答1:


If you try @azizbekian's path, I wrote about this here, created new test rules here and tested it here

I confirm @Testujaca Malpeczka path works on Travis-ci for Android APIs 17-22 as discussed here

If you are looking for a solution for latest Android APIs and tools, work in progress here and here

before_script:
  # Wait for emulator fully-booted and disable animations
  - android-wait-for-emulator
  - 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 input keyevent 82 &

It also works in Circle-ci and probably any continuous integration build server, see broken link here

test:
  pre:
    - ...
    - circle-android wait-for-boot
    - adb shell input keyevent 82
    - 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

My extended test rules work for Android APIs 15-22, and there was a bug in Android 23 emulator.

I'll try it for later versions 24+ using android-topeka sample another day, probably it works.

Any help, improvement or effective alternative using sdkmanager would be much appreciated.




回答2:


If it possible use adb shell command:

adb shell settings put global window_animation_scale 0.0
adb shell settings put global transition_animation_scale 0.0
adb shell settings put global animator_duration_scale 0.0

tested on jenkins ci



来源:https://stackoverflow.com/questions/43370329/how-to-disable-android-emulator-animations-in-travis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!