DroidRun: Unlocking AI Phone Automation

DroidRun is a new era of AI automated mobile phone operations. It makes Android devices smarter.
Core content:
1. Introduction to the DroidRun framework and its differences from traditional automation tools
2. Prerequisites and steps for installing DroidRun
3. How to configure environment variables and use CLI for device control
DroidRun: AI Automation for Mobile Phones
Technological breakthrough: from "browsing web pages" to "moving mobile phones"
DroidRun is a powerful framework for controlling Android devices through LLM agents. It uses natural language commands to automate Android device interactions. Traditional automation tools such as BrowserUse focus on web operations and ComputerUse handle desktop tasks, while DroidRun is the first to open up the closed loop between LLM and mobile OS.
Feature highlights
Control your Android device using natural language commands Support for multiple LLM providers (OpenAI, Anthropic, Gemini) Easy to use CLI Extensible Python API for custom automation
Quick start with DroidRun
Installation prerequisites
Android device (developer mode/USB debugging required) Python 3.8+ (Anaconda environment recommended) Dependency library installation: pip install droidrun
Install ADB
Windows: Download the ZIP package (https://developer.android.com/studio/releases/platform-tools) macOS: brew install android-platform-tools
Linux: sudo apt install adb (Ubuntu/Debian) or sudo pacman -S android-tools (Arch)
After installation, configure the environment variables
Install the DroidRun Portal app
DroidRun requires the DroidRun Portal app to be installed on your Android device:
Download the DroidRun Portal APK from the DroidRun Portal repository (https://github.com/droidrun/droidrun-portal) Installing apps using DroidRun:
droidrun setup --path=/path/to/droidrun-portal.apk
Or install using ADB:
adb install -r /path/to/droidrun-portal.apk
Setting API Keys
Create a .env file in the working directory and set the environment variables:
export OPENAI_API_KEY="your_openai_api_key_here"
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
export GEMINI_API_KEY="your_gemini_api_key_here"
Load environment variables from a .env file:
source .env
Connect Android Device
# Device List
droidrun device
# Connect your device
droidrun connect 192.168.0.1
Verify the settings
droidrun status
Using CLI
Basic method
droidrun "Open Settings app"
Use options
# Using OpenAI
droidrun "Open Calculator" --provider openai --model gpt-4o-mini
# Using Anthropic
droidrun "check battery level" --provider anthropic --model claude-3-sonnet-20240229
# Using Gemini
droidrun "Install and open Instagram" --provider gemini --model gemini-2.0-flash
Additional Options
# Specify the device
droidrun "Open Chrome and search for weather" --device yourdevice1
# Set the maximum number of steps
droidrun "Open Settings and enable dark mode" --steps 20
Python Script Example
#!/usr/bin/env python3
import asyncio
import os
from droidrun.Agent.react_agent import ReActAgent
from droidrun.agent.llm_reasoning import LLMReasoner
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
async def main () :
# Create an LLM instance (choose your preferred provider)
llm = LLMReasoner(
llm_provider = "gemini" , # can use "openai", "anthropic", or "gemini"
model_name = "gemini-2.0-flash" , # Select model
api_key=os.environ.get( "GEMINI_API_KEY" ), # Get the API key
temperature = 0.2
)
# Create and run the agent
agent = ReActAgent(
task= "Open the Settings app and check the Android version" ,
llm=llm
)
steps = await agent.run()
print( f"Execution completed with {len(steps)} steps" )
if __name__ == "__main__" :
asyncio.run(main())