Install the python environment as follows:
$ git clone https://github.com/mj-support/AndroidAgent.git
$ cd AndroidAgent
$ conda env create -f environment.yml
$ conda activate AndroidAgent
Download and install Android Studio as it contains the necessary SDK, ADB and emulator tools. Add ADB and the Android emulator to $PATH
to simplify the usage:
# for Linux + Bash
$ echo 'export PATH=$PATH:~/Android/Sdk/platform-tools' >> ~/.bashrc
$ echo 'export PATH=$PATH:~/Android/Sdk/emulator' >> ~/.bashrc
$ source ~/.bashrc
# for Mac + Zsh
$ echo 'export PATH=$PATH:~/Library/Android/Sdk/platform-tools' >> ~/.zshrc
$ echo 'export PATH=$PATH:~/Library/Android/Sdk/emulator' >> ~/.zshrc
$ source ~/.zshrc
To use models/airplane.zip
, please follow the next steps. You can also configure your own Android Virtual Device (AVD) with your own settings instead. In this case you might have to start a new training run to let the agent adapt to a the new evironment. You can see the configured AVDs with $ emulator -list-avds
.
- To configure your own Android Virtual Device (AVD) you need to open Android Studio.
- Click on 'More Actions' in the 'Welcome to Android Studio'-welcome menu and select 'Virtual Device Manager'.
- Create a new virtual device by clicking on the '+'
- Select 'Pixel 2' as hardware, 'VanillaIceCream' as system image and use 'my_avd' as AVD name and click 'Finish'
$ emulator -avd my_avd -no-boot-anim -netdelay none -no-snapshot -wipe-data -verbose -no-audio -gpu swiftshader_indirect -no-snapshot -read-only -partition-size 512 &
# for headless mode
$ emulator -avd my_avd -no-window -no-boot-anim -netdelay none -no-snapshot -wipe-data -verbose -no-audio -gpu swiftshader_indirect -no-snapshot -read-only -partition-size 512 &
# check your emulator-ID or look different for usable emulators
$ adb devices
You can start the training with the following command
$ python3 main.py
The resulting model will be saved in the models/
directory.
So far, only the airplane task has been implemented, but the code is designed to allow smooth expansion for a wide range of tasks.