Launching the first application in Android Studio is a moment that separates theory and practice. Many beginners encounter errors even at the stage of setting up the environment, and experienced developers sometimes lose sight of optimizing the build process. This article will help you figure out how to properly launch a app in Android Studio โfrom creating a new project to debugging on a physical device.
We will look at all the key steps: choosing an assembly configuration, setting up an emulator, connecting a smartphone via ADB, and also look at typical errors like Installation failed or Emulator not responding. We will pay special attention to the subtleties that are rarely mentioned in the official documentation - for example, how to speed up the first launch of the emulator or why the application may not open on some versions Android.
If you are just starting your journey in Android development, this guide will become your cheat sheet. Experienced programmers will find here tips on optimizing the workflow and diagnosing unobvious problems.
1. Preparing Android Studio for the first launch
Before launching the app, make sure that your development environment is configured correctly. Android Studio requires preliminary configuration, especially if you installed it for the first time. Here's what you need to check:
- ๐ SDK updates: Go to
Tools โ SDK Managerand install the latest versions Android SDK Platform and Android SDK Command-line Tools. - ๐ง Plugins: Make sure plugins are activated
Android SupportiGoogle ServicesvSettings โ Plugins. - ๐๏ธ Gradle cache: Clear the cache via
File โ Invalidate Caches / Restartif synchronization errors occurred previously. - ๐ ๏ธ Java JDK: Android Studio requires
JDK 11or later. Check the version in the terminal with the commandjava -version.
One โโof the most common sources of problems is incompatibility of Gradle versions. If, when synchronizing a project, you see an error like Gradle project sync failed, open the file gradle-wrapper.properties in the project root and update the distribution line:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
Also check the file build.gradle (Project) โit should contain the current version plugin Android Gradle Plugin:
classpath 'com.android.tools.build:gradle:8.1.0'
If Android Studio takes a long time to load dependencies when first launched, open File โ Settings โ Build, Execution, Deployment โ Gradle and enable the option Offline work. This will speed up the build, but will require manual updating of dependencies when changes build.gradle.
2. Creating a new project: step by step
To start the app, you first need to create a project. In Android Studio this is done through the wizard New Project. Let's look at the key points:
- Selecting a template: For the first launch, select
Empty Activityโthis is the minimum required structure with one screen. - Name and package: Specify
Name(application display name) andPackage name(a unique identifier in the formatcom.example.myapp). - Language programming: Kotlin (recommended by Google) or Java. For beginners, it is easier to start with Javaif you are familiar with it.
- Minimum SDK version: Select
API 21 (Android 5.0)or higher. You should not go lower - this will narrow the audience of users.
After creating the project Android Studio will automatically generate the file structure:
- ๐
app/src/main/java/โ source code (MainActivity.kt or MainActivity.java) - ๐
app/src/main/res/โ resources (layouts, images, lines) - ๐
app/build.gradleโ module assembly configuration - ๐
AndroidManifest.xmlโ application manifest
Pay attention to the file activity_main.xml in the folder res/layout โthe layout of the main screen is stored here. By default, there will be simple text. "Hello World!"It can be edited manually or through a visual editor Design.
What to do if the project is not created?
If it appears when creating a project error "Failed to create project", check:
1. Is there enough disk space (at least 3 GB of free space is required).
2. Are there any Cyrillic characters or spaces in the project path.
3. Is Android Studio running as administrator (sometimes required for writing to system folders).
3. Setting up the Android emulator
The emulator allows you to test the application without a physical device. However, setting it up is often difficult. Here's how to create a virtual device (AVD) Right:
- Open
Tools โ Device Manager. - Click
Create Deviceand select the model (for example, Pixel 5). - Indicate the system: recommended Android 13 (API 33) or newer.
- In section
System Imageselectx86_64(for PC) orARM(if you plan to test on Mac M1/M2). - Configure the emulator settings:
RAM(minimum 2 GB),Internal Storage(2 GB), enableHardware - GLES 2.0to speed up graphics.
After creating the emulator, you can launch it through the Play v Device Managerbutton. The first launch may take several minutes - the emulator downloads the necessary components. To speed up the process:
- ๐ Use Quick Boot (enabled in the emulator settings).
- ๐พ Create snapshot (
Snapshot) after the first boot. - ๐ Disable animation in the emulator developer settings (
Settings โ Developer options โ Window animation scale โ Off).
ARM-based emulators are slower than x86, but more accurately simulate real devices. If your processor supports virtualization (Intel VT-x or AMD-V), enable it in the BIOS for speedup.
Is it installed Hyper-V (for Windows) or KVM (for Linux)?
Are there enough RAM allocated (minimum 4 GB for emulator + system)?
Are other resource-intensive apps disabled?
Are video card drivers updated (to speed up OpenGL)?-->
4. Launching the app on the emulator
When the project and the emulator are ready, you can start launching. Here are the step-by-step guide:
- Make sure that the correct module is selected in the top panel ( Android Studio correct module selected (
app) and device (your emulator). - Press the green button
Run(orShift + F10). - Wait for the project to build. In the window
Build Outputyou will see the process log. - After successful compilation, the emulator will automatically open your application.
If the launch does not occur, check:
| Error | Cause | Solution |
|---|---|---|
Error: app type already present |
Dependency conflict in build.gradle |
Run File โ Invalidate Caches and rebuild the project |
Emulator: PANIC: Missing emulator engine |
The emulator for the selected one is not installed architecture | Reinstall the system via SDK Manager โ SDK Tools โ Android Emulator |
Installation failed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED |
Error in AndroidManifest.xml |
Check tags <uses-sdk> and <application> for correctness |
Device not authorized |
The emulator is not authorized for debugging | Restart the emulator and confirm the resolution on the device |
If the application starts, but you see a blank screen or an error "App not installed", check:
- ๐ Is it correct?
package namevbuild.gradle? - ๐ฑ Is there enough space on the virtual device?
- ๐ Is the installer of unknown sources blocked in the emulator settings?
Always start the emulator IN ADVANCE - waiting for it to load while building the project is ineffective. Open the emulator 1-2 minutes before pressing Run.
5. Running on a physical device
Testing on a real smartphone or tablet gives more accurate results than an emulator. To do this you need:
- Enable developer mode on the device:
- Go to
Settings โ About phone. - Click 7 times on
Build number. - Return to
Settings- the item will appearFor Developers.
- Go to
Settings โ For developers โ USB debugging.Run/Debug configurations.If the device is not detected, do:
- ๐ Check that the cable supports data transfer (not only charging).
- ๐ Switch USB mode to
File transfer (MTP)in the notification shade. - ๐ฅ๏ธ Install drivers ADB for your model (for example Google USB Driver for Nexus/Pixel devices).
- ๐ Enter in the terminal Android Studio the command:
adb devicesIf the device is displayed as
unauthorized, confirm permission to phone.
On some devices (for example, Xiaomi, Huawei), you additionally need:
- ๐ Allow
Installation from unknown sourcesin the security settings. - ๐ Enable
USB debugging (security options)in the developer menu. - ๐ฑ Disable
MIUI Optimization(for Xiaomi), if the application crashes on startup.
If the application is installed but closes immediately, check the logs in Logcat (tab at the bottom of Android Studio). Filter the output by tag AndroidRuntime โthere will be crash errors there.
6. Optimizing the launch process
Building and launching a project in Android Studio can take a lot of time. Here's how to speed up this process:
- โก Instant Run: Enable in
Settings โ Build, Execution, Deployment โ Instant Run(does not work with all code changes). - ๐๏ธ Clear cache: Perform periodically
File โ Invalidate Caches / Restart. - ๐ฆ Multi-module projects: Divide the project into modules (
app,core,features) for parallel assembly. - ๐ Gradle daemon: Enable
File โ Settings โ Build, Execution, Deployment โ Gradle โ Enable Gradle daemon.
To speed up the emulator:
- ๐ฅ๏ธ Use emulator with support for hardware acceleration (in the AVD settings, select
Hardware - GLES 2.0). - ๐พ Create snapshot (
Snapshot) for fast loading. - ๐ง Disable unnecessary emulator functions (for example,
Live WallpaperorMulti-Window).
If you are working with Kotlin, add the following lines to gradle.properties to speed up compilation:
kotlin.compiler.experimental=true
kotlin.compile.incremental=true
It is also useful for large projects:
- ๐ฆ Use dynamic features (Dynamic Feature Modules) to load parts of the application on demand.
- ๐ Configure caching dependencies in
gradle.properties:org.gradle.caching=true
The fastest way to test small changes is to use Apply Changes (lightning button next to Run). This updates the code without completely rebuilding the APK.
7. Diagnosis and solution of common errors
Even experienced developers encounter errors when starting up. Let's look at the most common ones and ways to solve them:
| Error | Possible cause | Solution |
|---|---|---|
Error: Failed to resolve: androidx.appcompat:appcompat:1.6.1 |
Problem connecting to repositories Google Maven | Check your Internet connection and update repositories in build.gradle:
|
Emulator: emulator: ERROR: x86 emulation currently requires hardware acceleration! |
There is no support for virtualization in BIOS | Enable Intel VT-x or AMD-V in the BIOS settings and install Intel HAXM (for Intel) |
Installation failed due to: 'Device not found' |
Device not detected through ADB |
Restart adb server commands:
|
Manifest merger failed: uses-sdk:minSdkVersion 15 cannot be smaller than version 16 |
Minimum SDK version conflict in dependencies | Update minSdkVersion in build.gradle or exclude the problematic library |
If the application starts, but does not work correctly:
- ๐ Check logs in Logcat (filter by
ErrororWTF). - ๐ฑ Make sure that permissions in
AndroidManifest.xmlare requested correctly (for example,INTERNETorCAMERA). - ๐ Clear application data on the device (
Settings โ Applications โ Your application โ Storage โ Clear data).
To diagnose performance problems:
- ๐ Use Android Profiler (
View โ Tool Windows โ Profiler). - ๐ Enable StrictMode to detect memory leaks or slow operations in the main stream.
- ๐ ๏ธ Check memory usage memory usage
Memory Profiler.
What to do if the emulator does not start?
Try:
1. Delete and create a new AVD with a different version of Android.
2. Launch the emulator from the command line:
emulator -avd YourAVDName -no-snapshot-load
3. Disable the antivirus (sometimes it blocks the emulator files).
8. data-i="297">In addition to standard tools
In addition to standard means Android Studio, there are tools that simplify launching and testing:
- ๐ง ADB AppControl: Utility for managing applications via
ADB(installation, uninstallation, clearing cache). - ๐ฑ Genymotion: Alternative emulator with advanced functions (for example, simulating GPS or SMS).
- ๐ Firebase Test Lab: Cloud testing on real devices (free up to 10 tests per day).
- ๐ LeakCanary: Library for detecting memory leaks in real time.
To automate the launch, you can use:
- ๐ค Gradle scripts: Write a custom task in
build.gradleto build and install APK on several devices simultaneously. - ๐ CI/CD: Configure GitHub Actions or Bitrise to automatically run tests on every commit.
Example of a Gradle task for installing an APK on all connected devices:
task installDebugToAllDevices(type: Exec) {commandLine 'adb', 'devices'
// Get a list of devices and install APK on each
doFirst {
def devices = commandLine.execute().text.readLines().tail().findAll { it.trim() }
devices.each { device ->
def deviceId = it.split()[0]
exec {
commandLine 'adb', '-s', deviceId, 'install', '-r', "${buildDir}/outputs/apk/debug/app-debug.apk"
}
}
}
}
To work with Firebase Test Lab add to build.gradle:
android {testBuildType "googlePlay"
}
dependencies {
implementation 'com.google.firebase:firebase-appdistribution-gradle:3.2.0'
}
If you are testing on several devices, use adb -s DEVICE_ID install app.apkwhere DEVICE_ID you can find out with the command adb devices.
FAQ: Frequently asked questions about running apps in Android Studio
๐น Why does the emulator run very slowly?
The speed of the emulator depends on several factors:
- ๐ฅ๏ธ Hardware acceleration: Make sure that it is enabled in the BIOS virtualization (
Intel VT-xorAMD-V). - ๐พ System type: Emulators on
x86_64work faster than onARM. - ๐ Dedicated resources: Increase the emulator RAM to 4 GB or more.
- ๐ Snapshots: Create a snapshot (
Snapshot) after the first boot.
Also try alternative emulators, for example Genymotion or BlueStacks (for testing games).
๐น How to run the application on your phone without a USB cable?
There are several ways:
- Wi-Fi ADB:
- Connect the device via USB and do:
adb tcpip 5555 - Disconnect USB and connect via Wi-Fi:
adb connect IP_DEVICE:5555
- Connect the device via USB and do:
โ ๏ธ Attention: When connecting via Wi-Fi, make sure your PC and device are on the same network.
๐น What to do if the "No devices found" error occurs during startup?
This error means that Android Studio does not see a single device to launch. Check:
- ๐ Is the device connected via USB and is debugging enabled?
- ๐ฅ๏ธ Is the emulator running (if you are using it)?
- ๐ Does
ADBsee the device? Run in the terminal:adb devicesIf the list is empty, restart
adb server:adb kill-serveradb start-server - ๐ง Are drivers installed for your device? For Samsung, Xiaomi and other brands may require proprietary drivers.
If the problem persists, try:
- Restart the device and PC.
- Use a different USB port (preferably
USB 3.0). - Disconnect other USB devices (they may conflict).
๐น Is it possible to run an Android app Studio without an emulator and a physical device?
Technically yes, but with limitations:
- ๐ฑ Cloud emulators: Services like BrowserStack or Sauce Labs allow test on real devices via a browser.
- ๐ฅ๏ธ Robolectric: Framework for unit testing Android code on the JVM without a device.
- ๐งช Instrumentation Tests: Can be run on Firebase Test Lab without a local device.
However, to fully test the interface and functionality you definitely need a real device or an emulator.
๐น Why, after changing the code, does the application not update at startup?
This can happen for several reasons:
- โก Instant Run disabled: Enable
Settings โ Build, Execution, Deployment โ Instant Run. - ๐๏ธ Gradle cache is out of date: Run
File โ Invalidate Caches / Restart. - ๐ฆ Incorrect build configuration: Check that the
Run/Debug Configurationsoption is selectedDeploy: Default APK. - ๐ Error in the code: If changes result in a compilation error, Android Studio may be using an old version of the APK.
To force a rebuild of the project, use:
Build โ Rebuild ProjectBuild โ Clean Project(thenRebuild)
If the problem persists, check the build logs in the window Build Output.