跳转至

Index

Android Environment Setup Guide

This guide will help you set up a local Android environment for AgentWorld.

Installation Steps

  1. Download and Install Android Studio
  2. Visit https://developer.android.com/studio
  3. Download and install the latest version for your operating system

  4. Install ADB and Android Emulator

  5. Open Android Studio
  6. Click on the top menu: Tools → SDK Manager SDK Manager
  7. Check the following components:
    • Android SDK Build-Tools
    • Android SDK Command-line Tools
    • Android Emulator
    • Android SDK Platform-Tools
  8. Click "Apply" to install these components Check components
  9. Important: Copy the installation directory path (you'll need it later for configuration)

  10. Create a Virtual Device

  11. From the main menu, select: View → Tool Windows → Device Manager Device Manager
  12. Click the "+" button, then "Create Virtual Device" button
  13. Select a device (e.g., Medium Phone), then click "Next" next
  14. Select a image (e.g., VanillalceCream), then click "Next" next
  15. Configure device settings as needed, then click "Finish"
  16. Important: Note down the AVD ID (device name) for later use avd id

  17. Configure in Your Code

  18. Method 1: Default Acquisition of Emulator and ADB Installation Paths
    • Only set the AVD_ID copied during the earlier installation process.
  19. Method 2: Manually Specify Emulator and ADB Installation Paths.Provide the following:
    • AVD_ID: The name of the virtual device you created
    • ADB path: Your SDK directory + "/platform-tools/adb"
    • Emulator path: Your SDK directory + "/emulator/emulator"

Example Code

Method 1

from examples.common.tools.android.action.adb_controller import ADBController

# Initialize the Android controller
android_controller = ADBController(avd_name="Medium_Phone_API_35")

Method 2

from examples.common.tools.android.action.adb_controller import ADBController

# Initialize the Android controller
android_controller = ADBController(
    avd_name="Medium_Phone_API_35",
    adb_path="/Users/username/Library/Android/sdk/platform-tools/adb",
    emulator_path="/Users/username/Library/Android/sdk/emulator/emulator"
)

# Now you can use this controller with your agent

Troubleshooting

  • If the emulator fails to start, try increasing the memory allocation in the AVD settings
  • Make sure your paths are correct for your operating system:
  • Windows: Use backslashes or raw strings (r"C:\path\to\sdk")
  • macOS/Linux: Use forward slashes as shown in the example

Additional Resources