Creating a mobile application is only half the way to its publication. Building APK in Android Studio is a critical stage on which stability of operation depends apps on user devices. Many novice developers encounter errors at this step, wasting hours searching for solutions. This article will help you understand the types of assemblies, the nuances of signing applications and optimizing the final package.

In 2026, the APK building process underwent changes: Google Play tightened security requirements, and Android Studio Giraffe and later automated some of the routine operations. We will look at current methods for all versions of the IDE, including working with Gradle 8.0+ i AGP 8.1. We will pay special attention to common errors that arise when generating a signed APK for publication in marketplaces.

Building an APK in Android Studio may seem complicated only at first glance. In fact, the process consists of several logical steps: preparing the project, choosing a build type, signing the application and optimization. In this article, we'll break down each step so you can confidently assemble APKs for testing or publishing.

It's important to understand that there are several types of APKs: debug (debug) for testing, release (release) for publishing, and bundle (AAB) for optimized uploading to Google Play. Each of them has its own characteristics and application. We'll take a closer look at how and when to use each type.

We'll also touch on APK optimization so that your app takes up less space on the user's device and loads faster. This is especially important in conditions of limited traffic and memory on many smartphones.

Types of APK builds in Android Studio

Before you start building, it is important to understand what type of APK you need. Three main options are available, each of which has its own purpose and features. Android Studio There are three main options available, each of which has its own purpose and features.

Debug APK is a version for debugging and testing. It is automatically signed with a debug key, which is created when the project is first launched. This APK can only be installed on devices in developer mode or via ADB. It contains debugging information, which makes it larger in size and less secure for distribution.

Release APK is the final version of the application, intended for publication in marketplaces or distribution among users. It requires signature with a special key, which you must create and keep secure. Release APK is optimized in size and does not contain debugging information.

Android App Bundle (AAB) is a new format recommended by Google for publication in the Play Market. Instead of one APK that contains code for all architectures, AAB allows Google Play to generate optimized APKs for each device. This reduces the download file size and speeds up installation.

  • ๐Ÿ”ง Debug APK โ€”for testing on real devices and emulators. Quickly assembled, but not suitable for publication.
  • ๐Ÿ“ฆ Release APK โ€”for distribution through marketplaces or directly to users. Requires a signature.
  • ๐ŸŒ Android App Bundle (AAB) โ€”optimal format for Google Play, reduces download size for users.

The choice of build type depends on your goals. If you are just starting development and want to test the application on your device, it is enough Debug APK. If you plan to publish an application on Google Play, it is better to use Android App Bundle, as it provides better optimization and meets modern requirements.

๐Ÿ“Š What type of build do you use more often?
Debug APK
Release APK
Android App Bundle
I donโ€™t know what it is

Preparing a project for APK assembly

Before building the APK, you need to make sure that your project is configured correctly. This will help avoid errors and simplify the process of generating the final file.

First, check the file build.gradle (Module: app). It must contain the correct build parameters, including minSdkVersion, targetSdkVersion and versionCode. For example:

android {

defaultConfig {

minSdkVersion 24

targetSdkVersion 34

versionCode 1

versionName "1.0"

}

}

Also make sure that the file gradle.properties indicates the latest versions of plugins and tools. For example:

android.useAndroidX=true

android.enableJetifier=true

org.gradle.jvmargs=-Xmx2048m

If you use libraries or dependencies, make sure they are compatible with your version Android Gradle Plugin (AGP). Incompatibilities may result in build errors. Check the latest versions in official documentation.

  • ๐Ÿ“ Check build.gradle for the correctness of the build parameters.
  • ๐Ÿ”„ Update dependencies in gradle.properties.
  • ๐Ÿ” Make sure the libraries are compatible with your version AGP.
  • ๐Ÿงน Clean the project (Build โ†’ Clean Project) before building.

โ˜‘๏ธ Preparing the project for building

Done: 0 / 4

Don't forget to synchronize the project with Gradle files by clicking Sync Project with Gradle Files in the top panel Android Studio. This ensures that all configuration changes are taken into account.

โš ๏ธ Attention: If you are using Kotlin, make sure the Kotlin plugin version is compatible with your AGP version. Inconsistency may lead to compilation errors.

Building Debug APK

Building Debug APK is the easiest and fastest way to get a working version of the application for testing. This type of build does not require additional settings and is signed automatically.

To build a Debug APK, follow these steps:

  1. Open your project in Android Studio.
  2. In the top menu, select Build โ†’ Build Bundle(s) / APK(s) โ†’ Build APK.
  3. Wait for the build process to complete. A notification will appear at the bottom APK(s) generated successfully.
  4. Click on the link locate in the notification to open the folder with the assembled APK.

The finished APK will be located in the folder app/build/outputs/apk/debug/. You can immediately install it on your device via ADB or simply transfer the file to your smartphone and open it.

Debug APK has several features:

  • ๐Ÿ”“ It is signed automatically with a debug key.
  • ๐Ÿ“ฆ Contains debugging information, which increases its size.
  • ๐Ÿšซ Not suitable for publication in marketplaces.

If you want to test the application on a real device, but do not want to build Debug APK, you can use the function Run 'app' (green button with arrow). In this case, the APK will be automatically built and installed on the connected device or emulator.

๐Ÿ’ก

To speed up the Debug APK build, you can disable code minification in build.gradle by adding minifyEnabled false to the block buildTypes { debug { ... } }.

Release APK build

Build Release APK requires more effort since this type of APK is intended to be published and must be signed with your private key. Without a signature, Google Play and other marketplaces will not accept your application.

First of all, you need to create a signing key. This can be done via Android Studio or command line. Let's look at both methods.

Method 1: via Android Studio

  1. Select Build โ†’ Generate Signed Bundle or APK.
  2. Select APK (not Android App Bundle) and click Next.
  3. Click Create new... to create a new key.
  4. Fill out the form:
    • Key store path โ€” path to the key file (for example, C:/keys/my_key.jks).
    • Password โ€” password for the key.
    • Alias โ€” key alias.
    • Password (Alias) โ€” password for an alias.
    • Validity (years) โ€” key validity period (recommended 25+ years).
  • Fill in information about you (name, organization, etc.).
  • Click OKthen Next and select build type release.
  • Click Finish and wait for the build to complete.
  • Method 2: via command line

    You can create a key using the utility keytoolwhich is included in composition Java JDK. To do this, run the command:

    keytool -genkey -v -keystore my_key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my_alias

    After creating the key, it can be used to sign the APK via Android Studio or Gradle.

    The finished Release APK will be located in the folder app/build/outputs/apk/release/It can be uploaded to marketplaces. or distribute through other channels.

    โš ๏ธ Attention: Keep the key file (.jks) in a safe place. Losing the key means that you will not be able to update your application on Google Play!

    Assembling Android App Bundle (AAB)

    Android App Bundle (AAB) is a modern app publishing format recommended by Google. Instead of one universal APK that contains code for all processor architectures, AAB allows Google Play to generate optimized APKs for each device, which reduces the download size and speeds up installation.

    To build AAB, follow these steps:

    1. Select Build โ†’ Generate Signed Bundle or APK.
    2. Select Android App Bundle (not APK) and click Next.
    3. Select an existing key or create a new one (as described in the previous section).
    4. Click Next, then select the build type release.
    5. Click Finish and wait for the build to complete.
    6. The finished AAB will be located in the folder app/build/outputs/bundle/release/. This file cannot be installed directly on the device - it is intended only for uploading to Google Play.

      Advantages of using AAB:

      • ๐Ÿ“‰ Reduces the size of the APK downloaded by the user by 15-20%.
      • ๐Ÿ”„ Automatically optimized for each device.
      • ๐Ÿ”’ Complies with modern Google Play requirements.

      If you publish an application for the first time, Google Play will automatically generate an APK from your AAB and provide it to users. When updating the application, you will need to download a new AAB.

      Build type Purpose Signature Size Installation
      Debug APK Testing Automatic Large To devices in developer mode
      Release APK Publishing Manual Optimized For any devices
      Android App Bundle Publishing on Google Play Manual Minimum for the user Only via Google Play

      Optimizing APK before building

      Optimizing APK is an important step that will help reduce file size and improve application performance. This is especially true for users with limited traffic or memory on the device.

      Here are several optimization methods:

      • ๐Ÿ—‘๏ธ Deleting unused resources: Enable shrinkResources true to build.gradleto remove unused images, lines and other resources.
      • ๐Ÿ” Code minification: Use minifyEnabled true and proguardRules to removing unnecessary code and renaming classes.
      • ๐Ÿ“ฆ Resource compression: Enable compression of PNG and other resources using tools like TinyPNG or WebP.
      • ๐Ÿ”„ Separation by architecture: Use abiFiltersto include in the APK only the necessary libraries for specific architectures (arm, x86, etc.).

      Example configuration for optimization in build.gradle:

      android {
      

      buildTypes {

      release {

      minifyEnabled true

      shrinkResources true

      proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

      }

      }

      splits {

      abi {

      enable true

      reset()

      include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'

      universalApk false

      }

      }

      }

      Using WebP format instead of PNG can reduce the size of images by 25-35% without losing quality. This is especially important for applications with a lot of graphics, such as games or social networks.

      Remember to test the optimized APK on different devices to ensure that all functions work correctly. Sometimes code minification can lead to errors if ProGuard rules are configured incorrectly.

      What to do if after optimization the application stops working?

      If the application crashes after enabling minifyEnabled or shrinkResources, check the proguard-rules.pro files. Some classes or methods may have been removed or renamed, resulting in errors. Add exceptions for critical classes using the -keep rule.

      Common errors when building APKs and their solutions

      When building APKs in Android Studio developers often encounter errors. Let's look at the most common of them and ways to solve them.

      1. Error "Failed to read key from keystore"

      This error occurs if you entered an incorrect password for a key or alias. Make sure the passwords are correct. If you forget your password, it is impossible to recover it - you will have to create a new key.

      2. Error "Duplicate files copied in APK"

      This problem occurs when there are duplicate files in the project, for example in libraries. The solution is to add to build.gradle the following:

      android {
      

      packagingOptions {

      pickFirst '**/*.so'

      }

      }

      3. Error "Execution failed for task ':app:processReleaseResources'"

      This error is usually associated with incorrect resources or conflicts in XML files. Check all files in the folder res/ for errors. Also make sure that all libraries used are compatible with each other.

      4. Error "Failed to resolve: some-library"

      This error means that Gradle cannot find the specified dependency. Check the correct spelling of the library in build.gradle and update the repositories. Sometimes cleaning the project (Build โ†’ Clean Project) and resynchronizing with Gradle helps.

      If you encounter an error that is not in this list, try looking for a solution in Stack Overflow or the official documentation Android. Often, build errors are associated with library incompatibility or incorrect settings in build.gradle.

      โš ๏ธ Attention: If you updated Android Studio or Gradle, some settings may be reset. Always check the project configuration after updates.

      Publishing an APK on Google Play

      After successful build Release APK or Android App Bundle you can publish your application in Google Play. To do this, follow these steps:

      Step 1: Create a developer account

      If you do not have an account yet, register on Google Play Console and pay the registration fee (for 2026 it is $25).

      Step 2: Prepare materials for publication

      You will need:

      • ๐Ÿ“ Application title (up to 50 characters).
      • ๐Ÿ“‹ Full description (up to 4000 characters).
      • ๐Ÿ–ผ๏ธ Icon (512ร—512 pixels, PNG).
      • ๐Ÿ“ธ Screenshots (minimum 2, recommended 8).
      • ๐ŸŽฅ Video (optional, but recommended).
      • ๐Ÿท๏ธ Category and tags.

      Step 3: Download APK or AAB

      In the section Release select the release type (Production, Beta, Alpha) and download the compiled file. If you use AAB, Google Play will automatically generate APKs for different devices.

      Step 4: Fill out your privacy information

      As of 2026, Google requires you to fill out a privacy section where you must indicate what data your app collects and how it is used.

      Step 5: Publish application

      After filling in all the data, click Submit for review. Moderation usually takes from several hours to 2-3 days.

      After publication, your application will become available to users depending on the selected release type (Production, Beta or Alpha).

      ๐Ÿ’ก

      Using Android App Bundle (AAB) instead of APK allows you to reduce the size of the file downloaded by users by 15-20% and meets modern Google Play requirements.

      How to build an APK without Android Studio?

      You can build an APK through the command line using Gradle. Go to the root folder of the project and run the command:

      ./gradlew assembleRelease

      The finished APK will be located in app/build/outputs/apk/release/. To build the Debug APK, use:

      ./gradlew assembleDebug
      Is it possible to update an application if you have lost your signing key?

      No, if you have lost your signing key, you will not be able to update an existing application on Google Play. You will have to publish it as a new application with a different package.

      What is the difference between an APK and an AAB?

      APK is a ready-to-install file that contains everything you need to work on any device. AAB is a package that is uploaded to Google Play, and the marketplace generates optimized APKs for each device. AAB allows you to reduce the download file size and makes it easier to support different architectures.

      How to reduce the size of an APK?

      To reduce the size of an APK:

      • Enable shrinkResources true i minifyEnabled true in build.gradle.
      • Use WebP image format instead of PNG.
      • Remove unused libraries and resources.
      • Separate APKs by architecture using abiFilters.

    Can AAB be installed on a device?

    No, AAB cannot be installed directly on device. This format is only intended for uploading to Google Play, which then generates an APK for users.