Engineering memory-performant Android apps

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Engineering memory-performant Android apps

Slides from the DevFest Kisumu 2026 workshop. Tuning R8 keep rules, building baseline profiles, hunting memory leaks and tracing slow starts used to need specialists and weeks of work. Now you can point an AI agent at your app: the Android CLI gives it the tools, Google's Android skills give it the know-how, and you check the numbers. Covers why memory and app size matter on the phones most people use, what the Android CLI and its skills can do, two hands-on labs (shrinking an app with R8, and measuring start-up with baseline profiles by comparing medians, not single runs), and what's new from Android Dev Summit. The lesson underneath it all: the agent proposes, measurement decides. The workshop app and step-by-step guide work with any agent the Android CLI supports, such as Antigravity, Claude Code or Codex.

Harun Wangereka

November 21, 2026

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

27 slides
  1. DevFest Kisumu · 21 November 2026 · Workshop Engineering memory-performant

    Android apps Smaller, faster, and proven Hands-on with the Android CLI, Google’s Android skills and an AI agent. You fix a real app, then measure what changed. by Harun Wangereka Android GDE · Senior Mobile Engineer SmileID Part of the team organising Droidcon x Fluttercon Kenya
  2. Scan 1 of 3 The workshop app Clone it on

    your group’s laptop. Today’s labs all happen in this app. github.com/wangerekaharun/kisumu-workshop
  3. Scan 2 of 3 Android CLI Install it with the

    one-line installer for your system, then run android init. developer.android.com/tools/agents/androidcli
  4. Scan 3 of 3 Antigravity CLI Install agy, the agent

    we use in the labs, and sign in. antigravity.google/docs/cli
  5. The plan Agenda Part What happens Setup, in groups Clone

    the app, set up the Android CLI and agy, add skills; first build starts While it builds Memory, R8, the Android CLI and its skills Lab 1: R8 On the big screen and in groups: measure, the agent reports and fixes, measure again Lab 2: start and scroll Started on stage during Lab 1; we measure it live. Phone groups join Stage demo The phone on screen, a preview without a phone, and a heap dump that finds a leak What else is new The rest of Android Dev Summit’s tools and performance news Results Each group’s before and after; the agent proposes, measurement decides Stuck at any point? Watch the big screen: the stage laptop runs every step.
  6. Setup · in groups Three steps, then the prompts 1

    Clone the sample app git clone https://github.com/wangerekaharun/kisumu-workshop 2 Set up the Android CLI and start the first build Run the installer line from the Android CLI page (QR 2), then these. Leave the build running and go to step 3. android init android sdk install platforms/android-37.0 build-tools/36.0.0 platform-tools gradlew assembleRelease 3 Set up the agent and its skills Install Antigravity CLI (agy), sign in, then add all 37 Android skills. On Windows, see QR 3. curl -fsSL https://antigravity.google/cli/install.sh | bash android skills add --all --agent=antigravity-cli --project=.
  7. While it builds Why it matters Memory, R8, and the

    tools that fix them, while your first build runs.
  8. Why it matters This used to need a platform team

    Before Now R8 tuning, baseline profiles, leak hunts, start-up traces: specialists, weeks of work, a platform team. Point your agent at the app. The CLI brings the tools, the skills the knowhow. You check the numbers. A small team can now do what only big teams could. That’s today’s point.
  9. Why it matters How memory slows an app down Clean-ups

    Squeezing Lots of throwaway objects mean lots of cleanups, and the screen stutters. Low on memory, Android compresses in the background, using your CPU. Closing apps Limits in Android 17 Out of memory, Android closes apps. Yours restarts from scratch. Each app gets a memory cap based on the phone’s RAM. Budget phones hit all four first. Less code and less work at start-up help on every phone.
  10. Why it matters · R8 R8 tidies your app when

    you build a release Removes Renames Rewrites Code and images nothing uses. Long names become short ones. Same work, fewer steps. 35% 30% 9% fewer “App not responding” errors fewer slow app starts smaller download Monzo’s results after turning R8 on fully, as shared at Google I/O 2026
  11. Why it matters · R8 Turn R8 on fully, then

    don’t hold it back Turn it on release { isMinifyEnabled = true isShrinkResources = true proguardFiles(getDefaultProguardFile( "proguard-android-optimize.txt"), "proguard-rules.pro") } Rules that hold it back -dontoptimize -dontshrink -dontobfuscate -keep class androidx.** { *; } A keep rule tells R8 “don’t touch this”. Only code your app finds by name while running needs one, and the rule should name just that code. Leave R8’s “full mode” on too. It’s the default. Google’s R8 analyzer scores your rules and points at the costliest. In Lab 1, a skill runs it for you.
  12. The tools What is the Android CLI? Android’s whole toolchain

    in one command, for you and your agent. For you For agents For CI Any terminal. No Android Studio. Built for agents, with Google’s skills. Same commands, JSON output. Works with any agent harness Antigravity · Claude Code · Codex · Cursor · Copilot · Gemini · 70+ more
  13. The tools Everything the Android CLI can do Set up

    Build and inspect Run and drive init sdk install skills list · add docs search build describe analyze preview render run · install layout · screen input tap · scroll emulator Phones and measuring device hub device remote profiler signals Each one starts with android, as in android analyze app.apk. Today we use init, sdk, skills, analyze, run, preview, device hub and profiler. You and the agent run the same commands, so you can check anything it tells you.
  14. New at Android Dev Summit 2026 What the CLI learned

    this year preview device remote device hub Compose previews with no phone. UI tasks 77% faster. A real phone from Google’s device lab. See and control any phone or emulator. profiler signals Agent plugins Traces and heap dumps. LeakCanary is on its way. Crashes and ANRs from real users. One install for Antigravity, Claude Code or Codex. From “What’s new in Android developer tools and performance”, Android Dev Summit 2026
  15. Android skills A skill is a folder the agent reads

    What you’ll see it do in Lab 1 r8-analyzer, installed .agents/skills/r8-analyzer/ SKILL.md references/ scripts/ convert_pb_to_json.py analyze.py SKILL.md says what the skill is for and the steps to follow. The agent reads it when your request matches. 1 Reads SKILL.md and follows its steps 2 Asks Gradle for R8’s report on the build 3 Scores the rules: how much of the app R8 may optimize 4 Finds the rule that holds R8 back the most 5 Stops at a report: this skill never edits your files
  16. Google’s official Android skills Which skill does what Skill What

    it finds or does Where android-cli Teaches the agent the Android CLI Setup r8-analyzer Finds the rules that hold R8 back. Reports only Lab 1 jetpack-compose-performance Finds screens redrawn too often Lab 2 anr-audit-and-fix Finds slow work that freezes the screen Lab 2 android-profiler Records memory, leaks and slow spots Stage demo android skills add --all --agent=antigravity-cli --project=. Using another agent? Swap antigravity-cli for yours: claude-code, codex, cursor, github-copilot, gemini and over 70 more.
  17. Lab 1 · every group R8 is on. It just

    isn’t doing much. 1 Measure android analyze on the release APK: about 7.8 MB, 20 MB of code, and “R8 Enabled=true”. 2 Ask for the report Use the r8-analyzer skill to report on this app’s release build and keep rules. 3 Ask for the fix, then measure Fix what the report found. Then build the release APK and measure it with android analyze. 4 Check it still works Open the list, a product and Tips. A smaller app that crashes doesn’t count. Keep the agent’s terminal in sight: it stops and waits when it wants your approval.
  18. Before Lab 2 What makes a list stutter and a

    start drag Images The main thread Lists The biggest things in memory. Load them at the size you show, in the background. It draws the screen. Heavy startup work makes it wait. Give rows keys, and don’t re-sort on every redraw. Two skills know these patterns: jetpack-compose-performance and anr-audit-and-fix. Lab 2 hands the app to both.
  19. Lab 2 · on stage, and groups with a phone

    Faster start, smoother list 1 Ask for the before numbers Install a release build on the phone. Measure its start time (middle of 10 launches) and janky frames while scrolling the list. What we measured Start time: 820 ms → 237 ms. Janky frames: 24% → 4%. 2 Ask for the fix Use the jetpack-compose-performance and anr-audit-andfix skills to make the list scroll smoothly and the app start faster. 3 Ask for the after numbers Measure start time and scrolling again the same way, and compare. An agent’s fix, same phone: 240 ms and 4.1%. One build gave 465, 366 and 229 ms in one afternoon. Use the middle of many runs, never one.
  20. Stage demo Three more things the CLI does Show the

    phone UI without a phone Find the leak android device hub android preview render The stage phone, live on the big screen. Draws a list row straight from the code. android profiler heapdump A snapshot of memory; the skill finds what stuck around. The leak prompt Install a debug build on the phone and open the app. Rotate the screen five times, then take a heap dump with android profiler. Use the android-profiler skill to find how many MainActivity instances are in memory and what keeps the old ones alive. Heap dumps hold user data such as tokens and images. Treat them as personal data.
  21. Android Dev Summit 2026 What else is new The rest

    of this year’s tools and performance news.
  22. New at Android Dev Summit 2026 More help with performance

    R8 Compose 1.13 The analyzer is built into AGP 9.3. Jetpack Keep replaces broad rules. Tracing shows why a screen redrew. Heap dumps from users Image memory Policy and security A new vitals metric for image memory. Skills that check Play policy and security. Crashlytics captures real out-of-memory crashes. From “What’s new in Android developer tools and performance”, Android Dev Summit 2026 Performance Analyzer Android Studio’s profiler, now in the CLI.
  23. New at Android Dev Summit 2026 And when you do

    open Android Studio Bring your own agent Change Review Views to Compose See what your agent changed, step by step. Moves XML layouts to Compose. XR emulators Android Bench Lightbuild Stable emulators for glasses. How AI models do on real Android tasks. An early, declarative build in YAML. Over 40 agents run inside Android Studio. From “What’s new in Android developer tools and performance”, Android Dev Summit 2026
  24. After today Take it home Turn R8 on fully Load

    images at the size you show Shrink resources, optimize rules, narrow keeps. Once, in the background. Hunt leaks Learn from real phones Android Studio’s profiler runs LeakCanary for you. Android 17 saves a heap dump when you run out of memory. Explore all 37 Android skills CameraX, Navigation 3, edge-to-edge, Play Billing, Wear OS and more · github.com/android/skills android skills list
  25. The agent proposes. Measurement decides. Our own benchmark: five runs

    said start-up was 12% faster. Twenty runs said 5%, and the likely range, −19% to +18%, included no change at all.

More Decks by Harun Wangereka

Other Decks in Programming