I have noticed a difference in size between the apk generated with these 2 options.
why is this happening ?
With the Build -> Build APK option:
MyProject\app\build\outputs\apk\app-debug.apk (Size 2.997 KB)
With the Run app option:
MyProject\app\build\outputs\apk\app-debug.apk (Size 3.300 KB)
Thanks.
Build APK is a shortcut for running the :app:assembleDebug
Gradle task (assuming you have the debug variant active in the Build Variants window).
When running the application, we first ask you which device you want to target and then pass the information to Gradle. Among other things, this lets us filter out unnecessary resources. If you have Instant Run enabled, we also package additional code into the APK.
When you create the build by Build->Build APK, the apk will contain all the resources for all the devices. i.e for ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi.
But in case you are running the app on device/emulator, it will detect that what the resolution of the phone is and will add only the resources with that resolution into the apk file. For ex, if your device is xhdpi , it will drop all other screen resolutions and will contain only xhdpi resources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With