9

I'm running the latest version of Android Studio (2.2 Preview 1) that was just released and trying to take advantage of some of the new tools.

The new APK Analyzer is very useful but I can't get it to work with debug builds, it only seems to be accurate for release builds.

Here is a screenshot of what the release build looks like, as you can see the method count looks accurate and all the android libraries that I am using are included.

Release APK

Now, if I pull in the debug build of the same application it looks totally different. All of my application code is missing, as well as all the third party libraries. And you can see that the method count has also been reduced dramatically.

Debug APK

So am I doing something wrong here? How can I get this analyzation to take place on my debug builds as well?

Note via James Lau on G+:

tool was designed to help you understand and reduce the size of your release APK, since that is what you publish. As such, you probably want to run it on your Release APK. You can leave Instant Run turned on for building Release APK as Instant Run only works on Debug.

Andrea Thacker
  • 3,440
  • 1
  • 25
  • 37
  • This sounds like something that should be reported as a bug. I believe https://code.google.com/p/android/issues/list is still the correct location – JesusFreke May 24 '16 at 21:01
  • Ok sounds good, maybe I'll go ahead and add that. – Andrea Thacker May 24 '16 at 21:38
  • 1
    Just wanted to follow up and clarify, this is definitely not a bug. Its just a side effect of Instant Run. – Andrea Thacker Jun 07 '16 at 15:08
  • @David Argyle Thacker: I can see you solved your issue, just want to add something here: "If you are using `minifyEnabled` or `shrinkResources` in your release gradle then It will shrink your code and resources that is why size of `dex` and `resources` will decrease dramatically"! for more information see: https://developer.android.com/studio/build/shrink-code.html – AndiGeeky Jan 06 '17 at 07:30

1 Answers1

8

Are you sure you have a complete debug build and not a APK file for an HOT or WARM SWAP?

Android Studio since 2.0 has a feature called "Instant Run" that allows to create some sort of "delta-APKs" for updating an app on-device after you made some small changes. The advantage is that you don't have to execute a full gradle build process and therefore such a HOT SWAP is much faster.

Those special HOT/WARM SWAP APKs include only the changes you made recently and some additional code for merging the created APK into the existing APK on-device.

Therefore you should try to execute "Rebuild project" or "Clean project" and see if the created debug APK is as you expect.

Robert
  • 39,162
  • 17
  • 99
  • 152
  • Yep, thats what it was. As soon as I uninstalled the app and disabled Instant Run I got the full dex file the next time I built my apk. – Andrea Thacker May 31 '16 at 16:08
  • 4
    If you want to use the APK Analyzer to look at a debug APK, you don't need to disable Instant Run. If you go to Build > Build APK, that will generate a regular debug APK that's not Instant-Run enabled. – James Lau Jun 16 '16 at 22:06