The premise is that the jdk,android and ant environments are configured on their own computers.
1, under the command line into the \android-sdk\tools\ folder, execute the command:
Android List
View the ID value of the SDK for the corresponding Android version number find your phone
or the corresponding version number of the simulator
2, still under the \android-sdk\tools\ folder, execute the command:
Android Create Uitest-project-n <name>-T <android-sdk-ID>-P <path>
Example:
Android Create Uitest-project-n autorunner-t 60-p f:\uiautomator
Autorunner: Is the name of the jar package to be generated
60: The ID value of the SDK for the Android version number of the corresponding phone or simulator version number
F:\uiautomator: Path of your own project (absolute path)
3. Enter the project folder under the command line and then execute the ant build, which will build the jar using Ant compilation.
The jar file is then generated under the Bin folder.
4. Installation and execution
ADB push <jar file path > data/local/tmp
adb shell uiautomator runtest <jar file name >-C <project class name, including package name >
Example:
Installation: adb push F:\uiautomator\bin\AutoRunner.jar data/local/tmp
Middle: F:\uiautomator\bin\AutoRunner.jar The full path of the jar package generated in the third step
DATA/LOCAL/TMP: Installation path for mobile phone or simulator
Execute: adb shell uiautomator runtest autorunner.jar-c com. Runner
Autorunner.jar: The third step of the generated jar package (not the full path)
Com.uiautomator.testcase.LaunchSettings: The full package name + class name of the class to execute
Android Uiautomator self-initiated test