Android: Debugging a release APK

A few weeks ago I was finishing up development on my app and was ready to release a beta version …Or so I thought.

I tested it thoroughly in development mode, but when I went to install the release version from the Play store, it kept crashing when I was doing something that worked perfectly fine in dev.

I was logging exceptions but there were no logs to be found, anywhere, including in the Play Developer Console.

Eventually I found out that the app was crashing because Proguard was trying to obfuscate my dependencies and I needed to explicitly exclude them. So, I tried deploying a “release” Build Variant to my USB device in Android Studio, but for some reason I still couldn’t reproduce the error.

Uploading .apks to the Play store and waiting for them to become available for download takes a long time (sometimes 30 minutes). Obviously, this is a terrible way to debug something.

What I really wanted to do was deploy the signed .apk file that Android Studio generated and that I was uploading to the Play store. I don’t know why it took me so long to figure out how to do this, despite my self-proclaimed Google-fu.

  1. Connect your USB device to your computer
  2. Go to the Android SDK folder. On a Mac, mine is installed at /Users/lori/Library/Android/sdk/
  3. Inside the platform-tools folder, there’s a file called adb (Android Debug Bridge). It’s a command line tool that lets you interact with your device.

You can check whether your device is connected by running

 ./adb device

Assuming there’s only one connected device, to install an apk that’s on your computer:

 ./adb install /path/to/your/app-release.apk

Finally, check out the logs for your app

./adb log | grep

Also check out the official docs for ADB for way more info.