Home Android & Kotlin Books Android Apprentice

30
Preparing for Release Written by Fuad Kamal

Heads up... You're reading this book for free, with parts of this chapter shown beyond this point as scrambled text.

You can unlock the rest of this book, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

So you finally built that app you’ve been dreaming about. Now it’s time to share it with the world! But where do you start?

By the end of this chapter, you’ll have the essentials you need to deploy your app to the Google Play Store. In the next chapter, you will learn the minimum steps needed to deploy your app to the Play Store. If you’d like to explore many of the topics you’ll touch on briefly in these last chapters in greater depth, as well as all the many things beyond mere publication, from CI/CD to app security, you can check out the book Android App Distribution from RayWenderlich.com. Although this chapter focuses primarily on preparing the app for the Google Play Store, most of the steps apply regardless of the publishing platform.

Here’s a quick overview of each step:

  • Clean up any debugging code you may have in the source.
  • Check the app version information.
  • Create a release version of the app with the correct signing key.
  • Test the release version on as many devices as possible.
  • Create a Google Play Console developer account.
  • Create screenshots, promotional graphics, and videos.
  • Fill out the app details on the Google Play Console.

Now you’re ready to walk through these items in detail.

Code cleanup

First, make sure your project and code are ready for release. Here are a few items to consider.

Choosing a good package name

Once you submit an app to the store, you can’t change the package name. The package name is embedded in AndroidManifest.xml, but you can set it in the app’s build.gradle.

defaultConfig {
  applicationId "com.raywenderlich.podplay"
  ...
}

Turning off debugging for release builds

By default, Android Studio creates debug and release build types for new projects.

buildTypes {
  release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
}
buildTypes {
  release {
    // Enables code shrinking, obfuscation, and optimization for
    // only your project's release build type.
    minifyEnabled true
  
    // Enables resource shrinking, which is performed by the
    // Android Gradle plugin.
    shrinkResources true
  
    // Includes the default ProGuard rules files that are
    // packaged with the Android Gradle plugin.
    proguardFiles getDefaultProguardFile(
      'proguard-android-optimize.txt'),
      'proguard-rules.pro'
  }
}

Removing logging

For your app’s security, you should remove debugging log messages from your app’s published version. Remove logging by deleting Log calls in the code.

-assumenosideeffects class android.util.Log {
  public static boolean isLoggable(java.lang.String, int);
  public static int v(...);
  public static int d(...);
  public static int i(...);
}

Verifying production settings

If your app communicates with external services, has update URLs, API keys, or other configuration items that are different during development, change them to the proper production settings.

Removing unused Resources

In Android Studio, run the Remove unused Resources command in the Refactor menu. Then check for stray files in your project. Look inside src to make sure it contains only source files. Check assets and res for outdated raw files, drawables, layouts, and other items. If found, remove them from the project.

Localizing

Perform any final localization tasks, such as translating your string files to other languages. You can broaden your app’s appeal with this simple yet often overlooked step.

Versioning

Before releasing the app, make sure you have a strong versioning strategy. It’s critical to maintaining the app and keeping a handle on support issues that may arise.

defaultConfig {
  applicationId "com.raywenderlich.podplay"
  minSdkVersion 23
  targetSdkVersion 30
  versionCode 1
  versionName "1.0"
  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Building a release version

Each time you build and run your app during development, Android Studio produces an APK file and installs it on the emulator or device. This APK file contains your app’s executable code as well as all of its resources.

Creating a signing key

To build a release version you first need to generate the signing key you’ll use to sign the app. The key stores in a keystore file. You must sign any future versions of the same app with the same key.

Checking your file size

Check the size of the app bundle file. If it’s over 500MB, you won’t be able to publish it as-is to the Play Store. You can get around this limitation by using dynamic feature modules.

Release testing

Test the release file on as many devices as you possibly can. Subtle bugs can show up when running the release versus debug versions of your app, especially when running on different hardware devices. At a minimum, test on at least one phone and one tablet.

Other publishing methods

In the next chapter you will learn how to distribute your app using the Play Store. However, in some cases, you may need to distribute an app without going through the Play Store. It might be an enterprise app that will never go public, or it might be a side project you’re distributing to friends and family.

Email distribution

Email requires the least amount of work on your part. All you do is attach the APK file to an email and have your users open the email on a compatible Android device.

Website distribution

Another option is to host the APK file on your website or a cloud share service such as Dropbox, Google Drive, or Slack. You can either send a link to the download location or point the users to the download page on your site. Whether the user taps the link from an email or the browser on the device, they’ll be prompted to install the APK.

Internal app sharing

There is a somewhat hidden feature in the Play Store that also allows you to directly distribute APKs to select small email lists. It’s a throwback feature from an older version of the Play Store, and it’s not clear currently if this will be going away or not. You will explore this in further detail in the next chapter.

Other app stores

There are some other app stores available for publishing your app. You may want to take time to explore which options are available.

Key Points

In this chapter you learned:

Where to go from here?

Congratulations, you now have an APK file ready for distribution! All that’s left is to create a new app release and upload your signed APK file. You’ll cover this and the publishing step in the next chapter.

Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.

Have feedback to share about the online reading experience? If you have feedback about the UI, UX, highlighting, or other features of our online readers, you can send them to the design team with the form below:

© 2021 Razeware LLC

You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

Unlock Now

To highlight or take notes, you’ll need to own this book in a subscription or purchased by itself.