Android App Distribution Tutorial: From Zero to Google Play Store

Learn how to generate a release build of your app, create a Google Play Store listing and finally release your app on the Play Store. By arjuna sky kok.

Leave a rating/review
Download materials
Save for later
Share
Update note: Arjuna Sky Kok updated this tutorial for Kotlin 1.5, Android 11, Android Studio 2020.3.1. Pablo Sanchez Egido updated this tutorial for Kotlin 1.3, Android 10 and Android Studio 3.5.3. Matt Luedke wrote the original.

You finished your Android app and celebrated its perfection with many flagons of ale (or pitchers of beer). Hooray! Now you’re ready to send your app out into the world. Soon it will reside not only on your Android device, but also on the devices of people around the globe. It’s an exciting step! But how will you do this? Well, the most common way to share an Android app is through the Google Play Store, where more than 2.8 million Android apps are available.

In this tutorial, you’re going to learn about both of the ways to distribute Android apps on the Google Play marketplace.

Note: This tutorial assumes you already have Android Studio installed. If not, look at the Installing Android Studio tutorial.

Getting Started

Download the starter project by clicking the Download Materials button at the top or bottom of the tutorial.

Of course, before you can publish an app, you need to have one that’s finished. For this tutorial, you’ll use a simple app that allows users to search for books, view their covers and share them with friends. :]

Open the project in Android Studio. Build and run to preview the app.

Application running

Note: If you have a finished Android app of your own, you can use it instead of the sample app.

Working With the Package Name

First, set a new package name for the app. The package name needs to be unique and remain unchanged in Google Play. Commonly, developers use the reverse domain name format, like this:

com.your_domain.app_name

The best way to refactor an app’s package name in Android Studio is to start in the Project pane. With the Android view chosen, select the settings icon:

Android Studio Project pane settings icon

You’ll see a drop-down menu with several project viewing options. Make sure Compact Middle Packages is unchecked.

Compact middle packages contextual menu

Now you can refactor the parts of the package name separately. Right-click on the package named raywenderlich, and select Refactor ▸ Rename. After you see a warning window, click Rename Package in the window.

Warning window with option to rename package

Next, you’ll see a new window where you can change the old name to your name or domain name. Click Refactor to enable renaming the package.

Rename package from raywenderlich to your project name

After you apply changes, check the Android view to make sure you changed your folder’s name.

Packaging Your App for Distribution

Android requires that APKs are digitally signed with a certificate before they can be installed. The certificate identifies the developer of the app. You can find more information about app signing in the official documentation.

There are two ways of distributing apps – using the traditional Android Application Package (APK) format and the new Android App Bundle (AAB) format. In August 2021, Google decided all new apps ready for publishing to Google Play have to be in the form of the Android App Bundle to support Dynamic Delivery. However, when you need a full application package just to do a clean install to a new device, use the APK format.

In the following sections, you’ll learn about both of them. But, before you jump into it, you need to create a keystore for your app.

Creating a New Keystore

To create a signed app bundle or package, you’ll use KeyStore — the storage place for your saved certificates. Be sure to keep these private!

Note: If you already have a keystore on your system, you can skip this section.

Luckily, you’ll need to use only one command line. Open Android Studio Terminal and add the following line to it:

keytool -genkey -v -keystore my-app-release-key.keystore -alias alias_name -keyalg RSA -sigalg SHA1withRSA -keysize 2048 -validity 10000

However, before you run it, you’ll need to modify it:

  1. Instead of my-app-release-key, specify a name for your keystore. Usually, developers replace it with company’s name.
  2. Replace alias_name with an alias for the new key, which is a name you’ll use later with the keystore path and password.
  3. Replace “10000”, with the number of years that the key will be valid. Make this at least 25 so that you can sign app updates with the same key throughout the lifespan of your app.

Once you fill in the information, run the command. Next, enter a password for the keystore. It needs to be at least 6 characters long, and it needs to remain private.

Running a terminal command for creating keystore

Then, you’ll be asked to re-enter the password. And, the terminal will ask you to answer a few personal questions — like, “what is your name?”, “what is your organization called?”, etc. All information will be stored in your keystore.

Terminal's questions for keystore

After you answer the questions, the terminal will finish the process, and Android Studio will create your keystore inside the app folder. Don’t lose it, because you’ll need it and its password info to make any updates to your app! If you are using a version control system, you shouldn’t be including this file in it. Don’t allow unauthorized people to have access to it, either.

With your app keystore ready, you can finally learn how and where to use it.

Creating a Signed APK

If you want to distribute the app in one file, you can create a Signed APK. With this method, you’ll package all your app’s resources into one zip file.

In Android Studio, select Build ▸ Generate Signed Bundle / APK…. You’ll see a window for choosing an app format. Select APK.

Window for choosing app format

Next, you have to sign the app. To do that, you need to use the keystore data created in the previous section. Select Choose existing… and navigate to its location. Then, fill out its password, alias name and enter a wanted password for the app key.

The window for populating keystore data

Note: In case you skipped the previous section and you don’t have a keystore in your system, create one by clicking Create new… and following the instructions. After you fill in everything needed, Android Studio will bring you back to the keystore data screen with all fields prepopulated.

Check Remember passwords to make things easier in the future and click Next.

The next step asks you to choose a destination folder for your signed bundle. Select the proper folder, then select release for the Build Variants. Finally, click Finish.

Selecting a Build Variant

When the packaging process is complete, Android Studio will notify you that your APK is ready and let you open it in the File Manager.

APK ready notification

Now that you generated your APK successfully, you can install it on a device by double-clicking on it.