Exec. Environment only developer anywhere Build Frequency very often few times Build Perf. Requirement should be fast doesn't matter App Size doesn't matter should be small
Tasks to get build Outputs ■ from build Inputs ■ (each Task has Inputs and Outputs) ◇ describe Dependencies of each build Task. ◇ Tasks Cache their Outputs and Skip execution, if not needed. ■ should be carefully implemented. [example bug] ◇ deployment can also be a part of the tasks. make, cmake, rake, ant, gradle, gyp, msbuild...
Dalvik Bytecode (classes.dex) ◇ Compiled and Zipped Resources and Assets (resources- debug.ap_) ◇ Native Libraries (libFooBarBaz.so) APK build takes ALL of those as Inputs. Any changes on them will trigger the build and update APK.
Device (via TCP, for emulator) ◇ Uninstall Previously Installed APK, if any ◇ the Device will... ■ Create and Adjust Permissions for the app. ■ Run `dex2oat` for ART Device.
monkey patching ■ replaces the path to dex, in app data path {ApplicationInfo.datadir}/files/studio-fd/dex/slice-*/*.dex ■ IncrementalClassLoader loads .dex-es from there ■ replaces the path to res and native libs similarly ■ using non-public Android API via reflection...
as possible. ◇ APP code -> small, frequently changed ◇ Library jars -> big, rarely changed ◇ Non-Instant-Build: everything is in one classes.dex. ◇ Instant Build ■ libraries are compiled to one different .dex. ■ Dex Sharding: split .dex to multiple files (default: 10) ■ Skip .dex-ing / uploading / dex2oat if input is older!
haven't changed ◇ Warm Swap: need to identify which resource values matter ◇ Changes to Manifest or referenced values: reinstallation There is some Gradle Task that scans changes and detects them. If it is buggy, Instant Run misbehaves. (InstantRunVerifier.java in Gradle 2.0 source tarball)