Eduardo Cucharro
Eduardo Cucharro

Reputation: 545

How to check the size of dependencies in an android app?

I'm working on an android app that already have many dependencies in it. I want to remove some starting by the bigger one's. How to check their size in the app?

Upvotes: 43

Views: 26278

Answers (4)

oleg.semen
oleg.semen

Reputation: 3061

In new Android Studio you can navigate build/outputs/apk (or build/intermediates/apk/debug) folder double tap on apk file you are interested (there should be separate file for each flavor) It will open a view like this: enter image description here there is lib folder where you can check a size of each library. also you can se a size of resources and other stuf.

Upvotes: 47

J. Doe
J. Doe

Reputation: 13043

I couldn't find my library in the list of the output of the APK Analyzer, so I went with the most straightforward solution:

  1. Create a new project
  2. Analyze the APK in release mode (Build -> Build Bundle -> Build APK)
  3. After thats done, click on the button 'analyze'
  4. Remember the size you see on the screen
  5. Add the dependency
  6. Repeat step 2 and 3 and than compare sizes

Upvotes: 0

Ram Mandal
Ram Mandal

Reputation: 1959

I don't know whether it helps you or not but I researched and found this.

select the project from the dropdown. go to your project. now select the libraries. right-click on the library you want to see the detail. choose the file path and click on the libraries or you can choose your dependency library. and go to the directory as shown in the figure below

enter image description here

enter image description here

enter image description hereenter image description here

Updated answer

With the latest android studio, you can see the size of apk with apk analyzer very powerful tool to analyze the apk.

  1. select Build from the menu and then select Analyze APK..
  2. give the path to the desired apk and press ok.

now you can review the size of all the files you want to.

output

Upvotes: 33

Reaper
Reaper

Reputation: 516

If anyone stumbles on this post, here is an even easier way to check.

All you have to do is compile your APK normally, take note of the size, then replace "implementation" for "compileOnly" in the library you want to check in your build.gradle.

This will generate an APK that crashes on runtime because it does not contain the library, but you can use it to compare and get the size said library adds to your APK.

Upvotes: 13

Related Questions