Analyzing the APK
One of the links in that toast is to “analyze” the APK.
Android Studio offers an APK Analyzer tool. Mostly, it exists to help developers see exactly what is in the APK, blended from all of the possible sources (your code, library code, etc.). For developers looking to reduce the size of the APK, the APK Analyzer is great for seeing where the space goes.
To bring up the APK Analyzer, either click that “analyze” link from a fresh build, or choose Build > Analyze APK at any time. The latter will bring up a typical file chooser dialog for you to navigate through the build/
directory to select the APK that you want to analyze:
The APK Analyzer then opens in a fresh tab:
The starter project’s APK is a 3.5MB file. This may seem rather large for an app that does not really do much. That is because:
- Google’s starter projects include a lot of libraries, and
- A normal debug build does not eliminate unused stuff from those libraries
We will look into how to address that latter problem much later in the book.
The table shows the breakdown of where the space goes. Of note:
- The
.dex
files — and, where relevant, thekotlin/
directory — represent your compiled code, both that you wrote, what was code-generated for you by Android Studio, and what you get from libraries - The
res/
directory and theresources.arsc
file represent your resources - The
AndroidManifest.xml
file is your manifest
We will explore these things much more later in the book and help you see how you might make your app smaller.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.