I have noticed a difference in size between the apk generated with these 2 options.
why is this happening ?
With the Build -> Build APK opti
This would probably be better answered if posed as an issue
to the Android Studio team. My guess is that you're using Instant Run
inside Android Studio (AS). This would explain the larger size since Instant Run generates proxy classes for changed code.
Edit the Run
configuration to build using gradle build
and you should be able to remove the extra code... But this WILL come with a much larger build/deploy time... If size of a debug build is really important to you then OK but for most this will ruin all the improvements the Android team has made to the DSL recently to improve speed