Exploring your apk with ClassyShark

Rajdeep Singh
AndroidPub
Published in
3 min readMar 1, 2018

So recently, while I was fighting with my apk to reduce its size, I came across this handy tool ClassyShark developed by Boris Farber. So this post is all about inspecting and digging around your apk (Btw apk size was reduced from 13mb to 8mb :P).

What is ClassyShark ?

ClassyShark is a free and open source tool. According to its github readme,

“ClassyShark is a standalone binary inspection tool for Android developers. It can reliably browse any Android executable and show important info such as class interfaces and members, dex counts and dependencies. ClassyShark supports multiple formats including libraries (.dex, .aar, .so), executables (.apk, .jar, .class) and all Android binary XMLs: AndroidManifest, resources, layouts etc.”

TL;DR — It is an incredibly lightweight and fast tool for decompiling your apks and analysing what the internals look like in the final executable.

That means analysing your apk and removing the unnecessary fat dependencies.

Let’s get started

Download the latest release jar and run java -jar ClassyShark.jar. This is what it should look like.

Now, click on the folder icon on top right side of the bar to load up your .apk, .jar, .aar, .class , .dex or .so file.

Once loaded, you’ll see the AndroidManifest.xml file along with the res and class folders.

And that’s it. Left side shows a tree consisting of files and folder and clicking them opens up the code on right side panel which is clearly divided into Fields, Constructors and Methods.

Inspecting the method counts

We android devs, sometimes find ourselves in a situation where our method counts reach the 64k limit imposed by the android platform and we need to either remove unnecessary code or make our apk multidex enabled.

To keep the method count in check, ClassyShark provides an easy interface. Click on the method count button above the apk name and it will open up this screen showing a graph with the method counts of each component as seen by the runtime.

A handy search option to the rescue

ClassyShark comes with a handy search field to filter the classes and other components by simple queries.

Apk Dashboard

Double clicking the apk name in the tree opens up the apk dashboard which is one of the most useful screen as it shows all the important info about the apk and its components under one roof.

  • It shows both method count and native method count for the dex files.
  • It finds out the duplicate dependencies, i.e. dependencies having same functionalities such as picasso/glide or okhttp/loopj in my case.
  • It shows the system broadcasts your app has registered for.
  • It points out the libraries that weren’t designed for Android.

Conclusion

It is an amazing tool to keep your apk in check and track down issues while dealing with third party dependencies and native libraries. So, forget the old way of using dex2jar and jd-gui or third party websites to decompile your apk and befriend the Shark.

Show some ❤ by hitting the clap button. Happy Coding

--

--