An Android APK usually contains these things.
assets/
lib/
META-INF/
res/
AndroidManifest.xml
classes.dex
Upon installation, the APK file is copied to /data/app
, and classes.dex
is extracted and "optimized" by running dex2oat
on it (on Android 5+ lib/
is also extracted). Result of the optimization is stored in /data/dalvik-cache/
so an app needs to be optimized only once per installation or update. Everything else is kept inside the APK. So the first answer is very clear: Things like assets
and res
that's required by the app must be provided, and they are inside the APK. The APK file is kept for supporting purposes. If you delete an APK, the app definitely won't start at all. (App: Where's my assets?)
Second, Google Play added support for "Delta Update" very long ago. In the delta update procedure, the difference between the old package and the new package is calculated. Then GP downloads the "Delta" and applies changes to the original APK to yield the updated APK, thus reducing download size.
An APK is always signed. This can prevent malicious modification to the package. You definitely don't want to install a modded app without knowing what is changed, or whether a virus has been injected. The META-INF/
inside the APK works for this purpose. Unofficial changes will result in non matching signature, and the Android system will refuse to install the modded app.
Also, when you update your Android OS, all dex files are "optimized" again so that you don't need to re-install them one by one. As is said above, optimization requires classes.dex
file from the original package.