close
Skip to content

Using Android Studio

codepath-wiki-review[bot] edited this page Jun 4, 2026 · 62 revisions

Android Studio is the official IDE for Android development from Google. It's built on top of the JetBrains IntelliJ IDEA Community Edition, so if you've used IntelliJ, PyCharm, or RubyMine, the user experience will feel familiar.

Build configuration

Android Studio uses Gradle as its build system, driven by the Android Gradle Plugin (AGP). New projects default to the Kotlin DSL (build.gradle.kts); older projects may still use the Groovy DSL (build.gradle). Both work; the examples below show Kotlin DSL with Groovy equivalents where the syntax diverges.

A typical Android project has this layout:

MyApp/
├── settings.gradle.kts         # which modules are part of the build
├── build.gradle.kts            # top-level (plugin versions shared across modules)
├── gradle/
│   ├── libs.versions.toml      # optional version catalog
│   └── wrapper/                # bundled Gradle wrapper
└── app/
    ├── build.gradle.kts        # module-level (dependencies, SDK targets, etc.)
    └── src/main/
        ├── java/               # or kotlin/
        ├── res/
        └── AndroidManifest.xml

Adding dependencies

Open the module-level build script (typically app/build.gradle.kts) and add entries to the dependencies block:

dependencies {
    // Remote artifacts (Google's Maven, Maven Central)
    implementation("androidx.appcompat:appcompat:1.7.1")
    implementation("com.google.android.material:material:1.12.0")

    // Local JARs / AARs in the libs/ directory
    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))

    // Another module in the same Gradle project
    implementation(project(":my-library"))
}

After editing the file, click Sync Now in the notification bar so Android Studio re-imports the configuration.

You can also drive this from the IDE: File → Project Structure… → Dependencies, pick a module, click the + button, and choose Library Dependency to search Maven for a coordinate. Android Studio appends the corresponding implementation(...) line to the module's build script.

The same dependencies in Groovy DSL (build.gradle):

dependencies {
    implementation 'androidx.appcompat:appcompat:1.7.1'
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    implementation project(':my-library')
}

Note: Use implementation (or, less commonly, api) — not the legacy compile configuration. compile was deprecated in AGP 3.0 (2017) and removed in Gradle 7 (2021). The difference matters: implementation dependencies stay out of consumers' compile classpaths and let Gradle do less work on incremental builds. Use api only when you genuinely need to re-export the dependency to consumers of your library module.

Library modules

To split shared code into its own module, choose File → New → New Module…, then Android Library. The generated build.gradle.kts applies the com.android.library plugin instead of com.android.application:

plugins {
    id("com.android.library")
}

Add the new module to your app's dependencies:

dependencies {
    implementation(project(":my-library"))
}

Library modules build as Android Archive (.aar) files (which can ship resources, the manifest, and assets — .jar cannot). The output lands in my-library/build/outputs/aar/ whenever the module builds.

Gradle wrapper

Every Android Studio project ships with the Gradle wrapper — a gradlew / gradlew.bat script and a gradle/wrapper/ directory. The wrapper downloads and runs the exact Gradle version the project was built against, so collaborators and CI servers don't need a system-wide Gradle install. Android Studio sets this up automatically; to change the Gradle version, edit distributionUrl in gradle/wrapper/gradle-wrapper.properties and re-sync.

Keyboard shortcuts

To switch keymap presets (Eclipse, Visual Studio, NetBeans, Sublime Text, etc.) or rebind specific actions, open the Settings dialog:

  • macOS: Android Studio → Settings… (or ⌘,)
  • Windows / Linux: File → Settings… (or Ctrl+Alt+S)

Navigate to Keymap in the left sidebar. Pick a preset from the dropdown at the top, or use the search box and right-click an action to bind a custom shortcut.

Other Tips

  • Clear Logcat between runs: open Run → Edit Configurations… and check Clear log before launch so the previous run's log statements don't bleed into the next launch.

  • Auto-import: Android Studio doesn't auto-import by default. To enable it, open Settings → Editor → General → Auto Import, check Add unambiguous imports on the fly, and add android.R to the Exclude from import and completion list so the framework's R class doesn't collide with your own. You can also press ⌘⌥O (macOS) / Ctrl+Alt+O (Windows / Linux) to optimize imports manually.

  • Code generation and cleanup: Code → Generate… creates getters, setters, equals()/hashCode(), and toString() skeletons. Reformat Code (⌘⌥L / Ctrl+Alt+L) and Optimize Imports (⌘⌥O / Ctrl+Alt+O) keep your file tidy.

  • Genymotion: if you're using Genymotion as your emulator and want Android SDK tools (Layout Inspector, adb, etc.) to recognize the device, point Genymotion at your Android SDK directory (e.g. on macOS, ~/Library/Android/sdk) under Genymotion → Settings → ADB.

References

Finding these guides helpful?

We need help from the broader community to improve these guides, add new topics and keep the topics up-to-date. See our contribution guidelines here and our topic issues list for great ways to help out.

Check these same guides through our standalone viewer for a better browsing experience and an improved search. Follow us on twitter @codepath for access to more useful Android development resources.

Clone this wiki locally