Skip to main content
This guide helps you diagnose and resolve common issues when working with the Mobile Use SDK.

Device Connection Issues

No Device Found

  • Error: DeviceNotFoundError: No device found. Exiting.
  • Agent initialization fails
1. Verify device connection
  • Android
  • iOS
adb devices
You should see your device listed with status “device”
2. Enable USB debugging (Android)
  • Settings → About Phone → Tap “Build Number” 7 times
  • Settings → Developer options → USB debugging
3. Trust computer (iOS)
  • Unlock your device
  • Tap “Trust” when prompted
4. Reset ADB
adb kill-server
adb start-server
5. Specify device manually
from minitap.mobile_use.sdk.builders import Builders
from minitap.mobile_use.sdk.types import DevicePlatform

config = (
    Builders.AgentConfig
    .for_device(platform=DevicePlatform.ANDROID, device_id="your_device_id")
    .build()
)
agent = Agent(config=config)

USB Connection Unstable

  • Random disconnections during automation
  • adb: error: device 'xxx' not found
1. Use a high-quality USB cablePoor quality cables can cause intermittent connections.2. Connect directly to computerAvoid USB hubs which can cause instability.3. Increase ADB timeout
adb shell settings put global adb_timeout 0
4. Use wireless debugging
# Enable TCP/IP mode
adb tcpip 5555

# Connect wirelessly
adb connect <device_ip>:5555
Ensure stable Wi-Fi connection for wireless debugging.

Servers Fail to Start

  • ServerStartupError during initialization
  • Ports already in use
  • Zombie processes from previous runs
1. Force clean zombie servers
agent = Agent()

# Kill any existing mobile-use servers
agent.clean(force=True)

# Now initialize
agent.init()
2. Check if Maestro is installed
maestro --version
If not installed, follow: https://maestro.mobile.dev/getting-started/installing-maestro3. Use custom ports
config = (
    Builders.AgentConfig
    .with_hw_bridge(url="http://localhost:9001")
    .with_screen_api(url="http://localhost:9000")
    .build()
)
4. Check for port conflicts
# Linux/Mac
lsof -i :8000
lsof -i :8001

# Windows
netstat -ano | findstr :8000
netstat -ano | findstr :8001

Task Execution Issues

Agent Not Initialized

  • Error: AgentNotInitializedError
Always call agent.init() before running tasks:
agent = Agent()

# Initialize first!
if not agent.init():
    print("Initialization failed")
    exit(1)

# Now you can run tasks
await agent.run_task(goal="Your task")

Task Times Out or Fails

  • Task gets stuck or fails to complete
  • Reaches max_steps limit
  • Unexpected results
1. Simplify the task goalBreak complex tasks into smaller steps:
# ❌ Too complex
await agent.run_task(
    goal="Open settings, go to network, enable airplane mode, "
         "wait 5 seconds, then disable airplane mode"
)

# ✅ Break into steps
await agent.run_task(goal="Open settings and go to network settings")
await agent.run_task(goal="Enable airplane mode")
await asyncio.sleep(5)
await agent.run_task(goal="Disable airplane mode")
2. Increase max_steps limit
task = (
    agent.new_task("Complex goal...")
    .with_max_steps(500)  # Default is 400
    .build()
)

await agent.run_task(request=task)
3. Enable tracing to debug
task = (
    agent.new_task("Your goal")
    .with_trace_recording(enabled=True)
    .build()
)

await agent.run_task(request=task)
# Check traces in mobile-use-traces/ directory
4. Be more specific in goals
# ❌ Vague
goal = "Check the weather"

# ✅ Specific
goal = "Open the Weather app, check the current temperature in Celsius for New York, and tell me tomorrow's forecast"

Incorrect Task Results

  • Task returns unexpected or incomplete data
  • Structured output fields are missing or incorrect
1. Use structured output with clear descriptions
from pydantic import BaseModel, Field

class WeatherInfo(BaseModel):
    current_temp: float = Field(
        ..., 
        description="Current temperature in Celsius"
    )
    condition: str = Field(
        ..., 
        description="Current weather condition (sunny, cloudy, rainy, etc.)"
    )
    tomorrow_forecast: str = Field(
        ..., 
        description="Detailed weather forecast for tomorrow"
    )

result = await agent.run_task(
    goal="Check weather for today and tomorrow",
    output=WeatherInfo
)
2. Provide more context in the goal
# ❌ Unclear
goal = "Get product info"

# ✅ Clear
goal = "Go to Amazon, search for 'wireless headphones', open the first result, and get the product name, price, and rating"
3. Use better LLM models for cortex
from minitap.mobile_use.config import LLM, LLMConfig, LLMWithFallback

profile = AgentProfile(
    name="accurate",
    llm_config=LLMConfig(
        cortex=LLMWithFallback(
            provider="openai",
            model="o4-mini",  # More powerful model
            fallback=LLM(provider="openai", model="gpt-5")
        ),
        # ... other components
    )
)

LLM and API Issues

API Key Authentication

  • Authentication errors
  • openai.error.AuthenticationError or similar
  • 401 Unauthorized responses
1. Verify API keys in .env file
.env
# Required based on your LLM config
OPENAI_API_KEY=sk-...
XAI_API_KEY=xai-...
OPEN_ROUTER_API_KEY=sk-or-...
GOOGLE_API_KEY=...
2. Load environment variablesThe SDK automatically loads .env files, but you can also set manually:
import os
from dotenv import load_dotenv

load_dotenv()  # Explicit load

# Or set programmatically
os.environ["OPENAI_API_KEY"] = "your_key"
3. Check API key validityTest your keys directly:
from openai import OpenAI

client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
response = client.chat.completions.create(
    model="gpt-5-nano",
    messages=[{"role": "user", "content": "test"}]
)
print("API key works!")

Rate Limiting

  • 429 Too Many Requests errors
  • Tasks slow down over time
1. Use different providersDistribute load across multiple LLM providers:
llm_config = LLMConfig(
    planner=LLM(provider="openai", model="gpt-5-nano"),
    cortex=LLM(provider="google", model="gemini-2.5-flash"),
    executor=LLM(provider="openrouter", model="meta-llama/llama-4-scout")
)
2. Use tier limitsCheck your API tier limits and upgrade if needed.3. Add delays between tasks
import asyncio

for task_goal in task_list:
    await agent.run_task(goal=task_goal)
    await asyncio.sleep(2)  # Brief delay

System Environment Issues

Python Version Compatibility

  • Import errors or syntax errors
  • SyntaxError or ModuleNotFoundError
Ensure you’re using Python 3.12 or higher:
python --version
# Should be 3.12.x or higher
Create compatible environment:

Import Errors

  • ModuleNotFoundError: No module named 'minitap'
  • Import errors for SDK components
1. Verify installation
pip list | grep minitap
# Should show: minitap-mobile-use
2. Reinstall the SDK
pip uninstall minitap-mobile-use
pip install minitap-mobile-use
3. Check virtual environmentEnsure you’re in the correct virtual environment:
which python
# Should point to your venv

Debugging Best Practices

Enable Comprehensive Logging

import logging

# Enable debug logging
logging.basicConfig(level=logging.DEBUG)

# Or for mobile-use specifically
from minitap.mobile_use.utils.logger import get_logger

logger = get_logger(__name__)
logger.setLevel(logging.DEBUG)

Use Trace Recording

Always enable tracing during development:
from pathlib import Path
from datetime import datetime

timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
trace_path = Path(f"/tmp/debug_traces/{timestamp}")

task = (
    agent.new_task("Your goal")
    .with_trace_recording(enabled=True, path=trace_path)
    .with_thoughts_output_saving(path=f"{trace_path}/thoughts.txt")
    .with_llm_output_saving(path=f"{trace_path}/output.json")
    .build()
)

Check Trace Contents

After a failed task, examine the traces:
ls /tmp/debug_traces/20241009_175416/

# View screenshots to see what the agent saw
# Read thoughts.txt to understand agent reasoning
# Check output.json for structured results

Getting Help

Filing a Bug Report

When filing an issue, include:
1

Environment Information

# Python version
python --version

# SDK version
pip show minitap-mobile-use

# OS
uname -a  # Linux/Mac
# or
systeminfo  # Windows
2

Device Details

  • Platform (Android/iOS)
  • Device model
  • OS version
3

Minimal Reproduction

Provide a minimal code sample that reproduces the issue
4

Error Messages

Full error traceback and logs
5

Traces (if applicable)

Include relevant screenshots from trace recording

Quick Reference

agent.clean(force=True)
agent.init()
# Android
adb devices

# iOS
idevice_id -l
import logging
logging.basicConfig(level=logging.DEBUG)
task = agent.new_task(goal).with_trace_recording(True).build()
adb kill-server
adb start-server

Next Steps

I