How to define and use a system property in Android Instrumentation test?

前端 未结 7 1040
时光说笑
时光说笑 2020-12-02 23:25

I am trying to use some arguments for an Instrumentation test. I noticed that I can read system properties with System.getProperty() function. So I use setprop

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 23:52

    System properties are read once when the root VM (Zygote) is started, which in turn spawns other Dalvik VMs like that of your application. That means you cannot set system properties on the fly.

    Try restarting Zygote using adb shell stop (wait until it has stopped) and adb shell start (wait until it has restarted), then try again. Or simply reboot the device or emulator.

提交回复
热议问题