Reputation: 658
I realized that, for some reason, Android Studio produces differently sized APK files than when I'm doing it manually using Gradle.
So, when I build file with Gradle (either gradle build
or gradle assembleDebug
) I am getting apks sized depending on whether I have activated ProGuard or not.
Without ProGuard I get a file with around 62k method references. With ProGuard activated I get an apk file with around 37k method references and 6mb heavy. And that seems okay.
But! When I run an app from Android Studio (with ProGuard activated), I get an apk file that is heavy around 3mb and, when imported for analysis has two dex files (classes.dex
and classes2.dex
), and both of them together shows only 300 method references, which is, obviously, not correct.
And app works normally no matter which way I've built it, I haven't seen any irregularities.
So, how and why does it happen? I tried to google little bit about how Android Studio does building process, but without success. I assumed that it essentially shouldn't make file any different than one I make calling gradle build
, but obviously that is not the case.
I am using Gradle 3.3 (as Gradle Wrapper) and Android Studio 2.3.3.
This are some numbers that might be relevant:
compileSdkVersion 26
buildToolsVersion '26.0.1'
minSdkVersion 16
targetSdkVersion 25
Upvotes: 1
Views: 473
Reputation: 60351
APK compile using the manual Run button on Android Studio, is optimized specifically for the device it is targeted only, while the APK compiled using gradle command, could be used to target any other devices. Check out
https://medium.com/@elye.project/dont-publish-your-manually-compiled-apk-c8ce2bf7e6b4
Not sure about why your APK is only 300 method references.
Upvotes: 1