Discord here: https://discord.gg/5Yv4kqjAbm
This Android application written in Kotlin is designed to fully automate a run of Uma Musume Pretty Derby by offering a set of options to customize what event rewards the bot should prioritise, stats to focus on, etc. Building on top of the work done for , this aims to solve the issue of spending too much hands-on time with completing a run for Uma Musume Pretty Derby.
Preview.07-13-2021.mp4
This project is purely for educational purposes to learn about Android automation and computer vision - basically a fun way to practice coding skills. Any usage is at your own risk. No one will be responsible for anything that happens to you or your own account except for yourself.
- Android Device or Emulator (Nougat 7.0+)
- For the best performance and stability on phones, the device needs to be at 1080p display resolution. The speed is also best at 1080p and for other resolutions, it becomes dependent on the manual scale that you can set in the settings. Right now it defaults to 1.0 which uses 1080p as the baseline. You can determine what scales may be good for you with the template match test that you can enable in the settings as well.
- If you change the display resolution while the overlay button is still active, you will need to restart the app in order for the display changes to persist to the
MediaProjectionservice.
- If you change the display resolution while the overlay button is still active, you will need to restart the app in order for the display changes to persist to the
- Tested emulator was on Bluestacks 5 (Pie 64-bit). Later versions of Bluestacks also should work. The following setup is required:
- Portrait Mode needs to be forced on always.
- Bluestacks itself needs to be updated to the latest version to avoid Uma Musume crashing.
- In the Bluestacks Settings > Phone, the predefined profile needs to be set to a modern high-end phone like the Samsung Galaxy S22.
- Device setup:
- 4 CPU Cores
- 4GB Memory
- Display resolution set to Portrait 1080 x 1920
- Pixel density 240 DPI (Medium)
- Note that other emulators like MuMu may have their 1080p at a different DPI other than 240. MuMu by default uses 480 DPI which will throw template matching and OCR off. It is highly recommended to force it to 240 DPI in the emulator settings for the best performance. The following are tested resolutions + DPIs:
- 1080x1920 240 DPI (from Bluestacks emulator default settings)
- 1080x2340 450 DPI (from native Samsung phone)
- For the best performance and stability on phones, the device needs to be at 1080p display resolution. The speed is also best at 1080p and for other resolutions, it becomes dependent on the manual scale that you can set in the settings. Right now it defaults to 1.0 which uses 1080p as the baseline. You can determine what scales may be good for you with the template match test that you can enable in the settings as well.
- The in-game graphics need to be set to
Standardinstead ofBasicfor best performance.
- Able to complete a run from start/midway to its completion.
- Settings to customize preferences and stat prioritization for Training Events.
- Handles races, both via skipping and running the race manually.
- Runs extra races to farm fans when enabled in the settings.
- A multitude of settings to configure including setting preferred stat targets per distance.
- Download the .apk file from the
Releasessection on the right and install it on your Android device. - Once you have it running, fill out the required section marked with * in the Settings page of the application. That would be the selection of the Character under the Training Event section.
- Now go back to the Home page after you have finished customizing the settings. The settings you have selected will be shown to you in the text box below the
Startbutton. - Now tap on the
Startbutton. If this is the first time, it will ask you to give the applicationOverlaypermission and starting up theAccessibilityservice.- You are also required to enable
Allow restricted settingsin theApp Infopage of the app in the Android Settings.
- You are also required to enable
- Once it is enabled, tapping on the
Startbutton again will create a popup asking if you wantMediaProjectionto work onA single apporEntire screen. Select theEntire screenoption. A floating overlay button will now appear that you can move around the screen. - Navigate yourself to the screen below that shows available options like Rest, Train, Buy Skills, Races, etc.
- Press the overlay button to start the automation process. For enabling app notifications, it is recommended to have a notification style that is small enough that it does not fully cover the top part of the screen where it contains the date, energy, turn number, etc. Or disable notifications if you do not want to worry about it.
- The bot will not start on any other screen than what is shown above.
- Install
Android Studioand create any new project or open an existing one in order for theLogcatconsole to appear at the bottom. - Connect your Android device to your computer:
- USB Connection: Enable
Developer OptionsandUSB Debuggingon your device, then connect via USB cable. - Wireless Connection: In Developer Options, enable
Wireless debuggingand pair your device using the pairing code or QR code. - Bluestacks or other emulators In the emulator settings, there is usually an option to open up to allow ADB wireless connection on
127.0.0.1:5555. Enabling that option should be enough but if Android Studio still does not see it, you can open up a terminal likecmdand typeadb connect 127.0.0.1:5555and it should sayconnected to 127.0.0.1:5555. You may need to typeadb disconnectto disconnect all ADB connections beforehand for a fresh slate.
- USB Connection: Enable
- In Android Studio's Logcat console at the bottom of the window, select your connected device from the device dropdown menu.
- Filter the logs by typing
package:com.steve1316.uma_android_automation [UAA]or just[UAA]in the search box to see only the logs from this app. - Run the app - you'll now see all of its logs appear in real-time as it runs.
NOTE: this only works when downscaling. If your device official resolution is lower than 1080p it will most likely not work.
-
Install the aShell You app. This allows you to run adb commands locally on your Android device, but requires Shizuku.
-
Install Shizuku, then start it by following these instructions.
-
With Shizuku started, you can then use aShell You to send the following adb commands:
- Change resolution to 1080p:
wm size 1080x1920 && wm density 240 - Revert changes:
wm size reset && wm density reset
You can also bookmark the commands for your own convenience.
- Change resolution to 1080p:
Alternatively, you can do the same on a computer if you cannot get the above to work out.
- Install adb. You will also to add the file path to the folder to
PATHvia theEnvironment Variablesetting underView advanced system settingsso that the terminal will know what theadbcommand should do. You may need to restart your computer to have your terminal pick up the changes. - Open up a new terminal anywhere (cmd, Powershell, etc).
- Plug in your Android device via USB. If all goes well, then executing
adb deviceswill show your connected device whenSettings > Developer options > USB Debuggingis enabled. There may be a popup on your Android device beforehand asking you to give permission to connect to ADB. Wirelessly connecting to ADB is also available via the AndroidSettings > Developer options > Wireless debugging - Execute the following commands individually to forcibly set your display resolution to 1080p and DPI to 240:
- Change resolution to 1080p:
adb shell wm size 1080x1920andadb shell wm density 240 - Revert changes:
adb shell wm size resetandadb shell wm density reset
- Change resolution to 1080p:
Note: If your home button disappears, reset the DPI back to default.
Make sure to use 1.0 scaling, as well as 80% confidence for best results in 1080p.
- Download and extract the project repository.
- Go to
https://opencv.org/releases/and download OpenCV (make sure to download the Android version of OpenCV) and extract it. As of 2025-07-20, the OpenCV version used in this project is 4.12.0. - Create a new folder inside the
/androidfolder namedopencvand copy the extracted files in/OpenCV-android-sdk/sdk/from Step 2 into it. - Open up the root of the folder in your preferred IDE/terminal and execute
yarn installto install the React Native dependencies from thepackage.json. - Your dev environment should now be set up. You can run the app on your connected Android device/emulator to have hot-reload changes for the frontend via the Metro HTTP server with
yarn android. You can also now build the APK withyarn buildoryarn build:cleanif you encounter problems. - You can set
universalApktotruein the app'sbuild.gradleto build a one-for-all .apk file or adjust theinclude 'arm64-v8a'to customize which ABI to build the .apk file for. - Note: New to React Native, you should not run the app directly from Android Studio. Have the Metro bundler run the app for you.
- jpn.traineddata from UmaUmaCruise by @amate
- eng.traineddata from tessdata
- MediaProjection - Used to obtain full screenshots
- AccessibilityService - Used to dispatch gestures like tapping and scrolling
- OpenCV Android - Used to template match
- Tesseract4Android - For performing OCR on the screen
- string-similarity - For comparing string similarities during text detection
- AppUpdater - For automatically checking and notifying the user for new app updates
- React Native - Used as the frontend
