~/talk

Introduction to Bytecode Instrumentation with AGP 8

Talkat DroidKaigi 2023 · 2023-09-14..09-16· [android, compilers-and-language-design]
slides:none on file

AGP 8 provides an official bytecode instrumentation API that hooks Gradle variants to ASM via the Android components block and replaces the old Transform API; the demo builds a Gradle plugin that uses ASM MethodVisitor and kotlinx.metadata to detect Kotlin data classes, find constructor parameter indices for a custom @Redacted annotation, rewrite the generated toString bytecode (removing getfield/aload and inserting LDC asterisk constants), and add a marker annotation — the example compiles and produces a UI showing redacted fields.

AI-written summary · about

  1. 0:00Welcome
  2. 1:15Bytecode instrumentation
  3. 2:58Why manipulate bytecode
  4. 5:03Android compilation pipeline
  5. 7:08AGP 8 instrumentation API
  6. 9:12Setup instrumentation transform
  7. 13:28Live demo
  8. 16:38Sample app demo
  9. 18:02Project structure & Gradle
  10. 20:52Visitor factory
  11. 24:22Class visitor logic
  12. 28:13Constructor parameters
  13. 31:00Rewriting toString
  14. 37:17Finalizing transformation
  15. 38:41Running transformed app
  16. 39:21Resources & closing
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.