Skip to main content

Android Development with Cursor: Setup and Tips

Android development with Cursor

Android development has traditionally been tied to Android Studio, Google's official IDE built on IntelliJ IDEA. Cursor, being a VS Code fork with AI capabilities, offers a different experience -- one that trades some Android-specific tooling for powerful AI assistance. This guide explains how to set up Cursor for Android development, when it makes sense to use it, and where Android Studio remains essential.

Android Studio vs Cursor: What You Gain and Lose

Before switching to Cursor for Android work, understand the tradeoffs:

FeatureAndroid StudioCursor
Layout Editor (XML visual)YesNo
Emulator integrationBuilt-inExternal
Gradle sync & buildNativeTerminal only
Logcat viewerBuilt-inNo
APK analyzerBuilt-inNo
Database inspectorBuilt-inNo
AI code assistanceBasic (Gemini)Advanced (Claude, GPT)
Natural language chatNoYes
Composer multi-file editsNoYes
VS Code extensionsNoYes
Customizable keybindingsLimitedFull

The decision is not binary. Many developers use Cursor for writing code and Android Studio for building, debugging, and running the emulator.

Setting Up Cursor for Android Development

1. Install Required Extensions

Cursor supports VS Code extensions. For Android development, install these:

  1. Open Cursor
  2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
  3. Search for and install:
    • Kotlin Language by mathiasfrohlich -- syntax highlighting and basic IntelliSense
    • Kotlin by fwcd -- advanced Kotlin support (choose one)
    • Android iOS Emulator by DiemasMichiels -- launcher for emulators
    • Gradle Language Support -- for build.gradle and settings.gradle files
    • XML Tools -- for Android manifest and layout files
// Recommended extensions in .vscode/extensions.json
{
"recommendations": [
"mathiasfrohlich.kotlin",
"vscjava.vscode-gradle",
"redhat.vscode-xml",
"diemasmichiels.emulator"
]
}

2. Open Your Android Project

You can open an Android project in Cursor just like any other folder:

# Navigate to your project
cd ~/Projects/MyAndroidApp

# Open in Cursor
cursor .
Gradle Files

Cursor can edit .gradle and .kts files, but it cannot sync Gradle or resolve dependencies the way Android Studio does. You will run Gradle commands from the terminal.

3. Configure Gradle Build Tasks

Set up VS Code tasks for common Gradle operations:

// .vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Debug APK",
"type": "shell",
"command": "./gradlew",
"args": ["assembleDebug"],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Run Tests",
"type": "shell",
"command": "./gradlew",
"args": ["test"]
},
{
"label": "Install Debug APK",
"type": "shell",
"command": "./gradlew",
"args": ["installDebug"]
},
{
"label": "Clean Build",
"type": "shell",
"command": "./gradlew",
"args": ["clean"]
}
]
}

Run tasks with Ctrl+Shift+B (Cmd+Shift+B on macOS).

Gradle Setup in Cursor

Gradle is the backbone of Android builds. In Android Studio, Gradle sync happens automatically. In Cursor, you manage it manually.

Common Gradle Commands

# Build the project
./gradlew build

# Build debug APK
./gradlew assembleDebug

# Build release APK
./gradlew assembleRelease

# Run unit tests
./gradlew test

# Run instrumented tests
./gradlew connectedAndroidTest

# Clean build artifacts
./gradlew clean

# View all available tasks
./gradlew tasks

Gradle Wrapper Issues

If the wrapper script is not executable:

chmod +x gradlew

On Windows, use gradlew.bat instead of ./gradlew.

Dependency Management

When you add a dependency to build.gradle or build.gradle.kts, Cursor will not auto-sync. You must run:

./gradlew build

Or use the Gradle daemon for faster subsequent builds:

./gradlew --daemon build
Gradle Daemon

The Gradle daemon stays resident in memory and speeds up builds significantly. Enable it by default by creating a gradle.properties file in ~/.gradle/ with org.gradle.daemon=true.

Emulator Integration

Cursor does not have a built-in emulator like Android Studio. You have two options:

Option 1: Launch Emulator from Terminal

# List available emulators
emulator -list-avds

# Launch a specific emulator
emulator -avd Pixel_7_API_34

Add this as a VS Code task for quick access:

{
"label": "Launch Emulator",
"type": "shell",
"command": "emulator",
"args": ["-avd", "Pixel_7_API_34"]
}

Option 2: Use the Emulator Extension

The Android iOS Emulator extension by DiemasMichiels adds an emulator launcher to Cursor's status bar.

  1. Install the extension
  2. Click the emulator icon in the status bar
  3. Select your AVD from the dropdown

Option 3: Keep Android Studio Open

Many developers simply keep Android Studio running for the emulator and Logcat, while editing code in Cursor. This is the most reliable approach.

Kotlin and Java Support

Cursor handles both Kotlin and Java well, but Kotlin support is stronger due to community tooling.

Kotlin

  • Syntax highlighting works with the Kotlin extension
  • Cursor Tab autocomplete is effective for Kotlin idioms
  • AI chat understands Kotlin coroutines, Flow, and Compose

Example prompt for Kotlin:

"Create a ViewModel in Kotlin that fetches user data using
Retrofit and exposes it as StateFlow. Handle loading and error states."

Java

  • Java support in Cursor is excellent (VS Code has mature Java extensions)
  • You can install the Extension Pack for Java by Microsoft for full IDE features
  • Cursor's AI works equally well with Java and Kotlin
// For full Java support
{
"recommendations": [
"vscjava.vscode-java-pack"
]
}

Android Jetpack Compose

Jetpack Compose is where Cursor shines. Since Compose is code-only (no XML layouts), the entire UI can be written and refined in Cursor:

@Composable
fun UserProfileCard(user: User) {
Card(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp)
) {
Column(modifier = Modifier.padding(16.dp)) {
Text(text = user.name, style = MaterialTheme.typography.headlineSmall)
Text(text = user.email, style = MaterialTheme.typography.bodyMedium)
}
}
}

Cursor can generate, refactor, and explain Compose code effectively because it is pure Kotlin.

The Dual-IDE Workflow

Based on community feedback, the most productive setup for Android development is:

TaskToolReason
Write Kotlin/Java codeCursorAI assistance, better editing
Edit XML layoutsEitherCursor works; Android Studio has preview
Build and deployAndroid StudioReliable Gradle sync and emulator
Debugging with breakpointsAndroid StudioSuperior debugger and Logcat
Compose UI developmentCursorCode-only, no preview needed
Profiling and analysisAndroid StudioCPU/memory/network profilers
  1. Open the project in both IDEs
  2. Edit code in Cursor -- use chat for explanations, Composer for refactors
  3. Build in Android Studio -- click the run button for emulator deployment
  4. Debug in Android Studio -- use Logcat and the debugger
  5. Commit from either -- both IDEs detect file changes via the filesystem

Limitations

What Cursor Cannot Do for Android

LimitationImpactWorkaround
No Layout EditorCannot visually edit XMLEdit XML manually or use Android Studio
No built-in emulatorCannot run apps directlyUse terminal or keep Android Studio open
No Logcat viewerCannot view logsUse adb logcat in terminal or Android Studio
No APK analyzerCannot inspect APKsUse Android Studio's Build Analyzer
No database inspectorCannot inspect Room databasesUse Android Studio or Stetho
Gradle sync not automaticMust manually run buildsUse terminal or task shortcuts

Known Issues

Issue: Kotlin extension shows errors for valid code

Solution: The Kotlin extension for VS Code is not as mature as Android Studio's. Some errors are false positives. Rely on Gradle builds for the real compilation status.

Issue: Compose preview does not work

Solution: Android Studio's Compose preview is not available in Cursor. Use the emulator or build the app to see UI changes.

Issue: R.java references show as unresolved

Solution: Run ./gradlew build once so that generated code is created. The Kotlin extension may still show warnings, but the code compiles.

Best Practices

1. Use Compose When Possible

Jetpack Compose eliminates the need for XML layout editing, making Cursor a much more viable primary editor for Android UI work.

2. Create Shell Scripts for Common Tasks

Automate repetitive Gradle commands:

#!/bin/bash
# scripts/build.sh
./gradlew clean assembleDebug && adb install app/build/outputs/apk/debug/app-debug.apk

3. Use ADB from Terminal

Learn ADB commands for quick device interactions:

# Install APK
adb install app/build/outputs/apk/debug/app-debug.apk

# View logs for your app
adb logcat -s "MyAppTag:D"

# Clear app data
adb shell pm clear com.example.myapp

# Screenshot
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png

4. Leverage Cursor's AI for Boilerplate

Android involves significant boilerplate. Use Cursor to generate:

  • RecyclerView adapters
  • Retrofit service interfaces
  • Room database entities and DAOs
  • ViewModel factories
  • Dagger/Hilt modules
Cursor prompt:
"Generate a Room database entity for a Todo item with id, title,
description, dueDate, and isCompleted fields. Include the DAO with
CRUD operations and a query to get completed todos."

Summary

Cursor is a viable tool for Android development, especially for Kotlin and Jetpack Compose projects. It is not a full replacement for Android Studio, but it excels at code writing, refactoring, and AI-assisted development.

Key takeaways:

  • Install Kotlin and Gradle extensions for basic IDE features in Cursor
  • Use Gradle commands from the terminal -- there is no automatic sync
  • Launch the emulator from terminal or use the Emulator extension
  • The dual-IDE workflow (Cursor for code, Android Studio for build/debug) is most reliable
  • Jetpack Compose projects work best in Cursor because they are code-only
  • Always verify builds in Android Studio before releasing

If your workflow is heavily dependent on visual layout editing, extensive debugging, or profiling, Android Studio remains essential. For pure code writing with AI assistance, Cursor is a strong alternative.


Last updated: June 2025