Skip to content

Android application written in Kotlin with the sole purpose of completely automating a run of Uma Musume Pretty Derby.

License

Notifications You must be signed in to change notification settings

steve1316/uma-android-automation

Repository files navigation

Uma Musume Automation For Android

GitHub commit activity GitHub last commit GitHub issues GitHub pull requests GitHub

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 Uma Android Training Helper, 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

Disclaimer

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.

Requirements

  • 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 MediaProjection service.
    • Tested emulator was on Bluestacks 5 (Pie 64-bit). 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)

Features

  • 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.

Instructions

  1. Download the .apk file from the Releases section on the right and install it on your Android device.
  2. 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.
  3. 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 Start button.
  4. Now tap on the Start button. If this is the first time, it will ask you to give the application Overlay permission and starting up the Accessibility service.
    1. You are also required to enable Allow restricted settings in the App Info page of the app in the Android Settings.
  5. Once it is enabled, tapping on the Start button again will create a popup asking if you want MediaProjection to work on A single app or Entire screen. Select the Entire screen option. A floating overlay button will now appear that you can move around the screen.
  6. Navigate yourself to the screen below that shows available options like Rest, Train, Buy Skills, Races, etc.

main screen

  1. 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.
    1. The bot will not start on any other screen than what is shown above.

To view Logs in Real-time

  1. Install Android Studio and create any new project or open an existing one in order for the Logcat console to appear at the bottom.
  2. Connect your Android device to your computer:
    • USB Connection: Enable Developer Options and USB Debugging on your device, then connect via USB cable.
    • Wireless Connection: In Developer Options, enable Wireless debugging and 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 like cmd and type adb connect 127.0.0.1:5555 and it should say connected to 127.0.0.1:5555. You may need to type adb disconnect to disconnect all ADB connections beforehand for a fresh slate.
  3. In Android Studio's Logcat console at the bottom of the window, select your connected device from the device dropdown menu.
  4. 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.
  5. Run the app - you'll now see all of its logs appear in real-time as it runs.

To set the phone's resolution to 1080p (faster and more accurate)

NOTE: this only works when downscaling. If your device official resolution is lower than 1080p it will most likely not work.

  1. Install the aShell You app. This allows you to run adb commands locally on your Android device, but requires Shizuku.

  2. Install Shizuku, then start it by following these instructions.

  3. 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.

Alternatively, you can do the same on a computer if you cannot get the above to work out.

  1. Install adb. You will also to add the file path to the folder to PATH via the Environment Variable setting under View advanced system settings so that the terminal will know what the adb command should do. You may need to restart your computer to have your terminal pick up the changes.
  2. Open up a new terminal anywhere (cmd, Powershell, etc).
  3. Plug in your Android device via USB. If all goes well, then executing adb devices will show your connected device when Settings > Developer options > USB Debugging is 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 Android Settings > Developer options > Wireless debugging
  4. 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 1080x1920 and adb shell wm density 240
    • Revert changes: adb shell wm size reset and adb shell wm density reset

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.

For Developers

  1. Download and extract the project repository.
  2. 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.
  3. Create a new folder inside the root of the project repository named opencv and copy the extracted files in /OpenCV-android-sdk/sdk/ from Step 2 into it.
  4. Open the project repository in Android Studio.
  5. Open up the opencv module's build.gradle. At the end of the file, paste the following JVM Toolchain block:
// Explicitly set Kotlin JVM toolchain to Java 17 to match the OpenCV module's Java target.
// Without this, Kotlin defaults to JVM 21 (especially with Kotlin 2.x), which causes a build failure:
// "Inconsistent JVM Target Compatibility Between Java and Kotlin Tasks".
// See: https://kotl.in/gradle/jvm/toolchain for details.
kotlin {
    jvmToolchain {
        languageVersion.set(JavaLanguageVersion.of(17))
    }
}
  1. You can now build and run on your Android Device or build your own .apk file.
  2. You can set universalApk to true in the app's build.gradle to build a one-for-all .apk file or adjust the include 'arm64-v8a' to customize which ABI to build the .apk file for.

Technologies Used

  1. jpn.traineddata from UmaUmaCruise by @amate
  2. eng.traineddata from tessdata
  3. MediaProjection - Used to obtain full screenshots
  4. AccessibilityService - Used to dispatch gestures like tapping and scrolling
  5. OpenCV Android - Used to template match
  6. Tesseract4Android - For performing OCR on the screen
  7. string-similarity - For comparing string similarities during text detection
  8. AppUpdater - For automatically checking and notifying the user for new app updates