●CC 2.1.332 — In 2.1.332 (11/25), skills from MCP servers show up in the / menu as server:skill (beta)●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 4 days left. Move to claude-sonnet-5-5●/SHIP — Users report a custom ship skill hidden behind the new built-in /ship command●NEW — New: Before Sonnet 4.5 retires, compare the 3 places its answers change●GEMINI 2.5 — Using Gemini 2.5 alongside Claude? From 12/1 requests reroute to newer models at their rates. 5 days left●JETBRAINS — Our guide to using Claude Code from JetBrains IDEs is the most-read page right now●CC 2.1.332 — In 2.1.332 (11/25), skills from MCP servers show up in the / menu as server:skill (beta)●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 4 days left. Move to claude-sonnet-5-5●/SHIP — Users report a custom ship skill hidden behind the new built-in /ship command●NEW — New: Before Sonnet 4.5 retires, compare the 3 places its answers change●GEMINI 2.5 — Using Gemini 2.5 alongside Claude? From 12/1 requests reroute to newer models at their rates. 5 days left●JETBRAINS — Our guide to using Claude Code from JetBrains IDEs is the most-read page right now
Per Callback, or Once at the Door? Deciding What Claude Code Should Touch on the Day I Installed an Ads SDK Migration Skill
Android's ads SDK is changing generations, and every callback will now arrive on a background thread. The official migration skill says to switch to the UI thread inside each callback; I chose to switch once, at the entrance of my ad wrapper layer. Three tools — an inventory scanner, an entrance-level normalizer, and a PreToolUse hook that fences Claude Code's edits on the migration branch — and the reasoning behind the choice.
In mid-August, an email arrived about the ads SDK I use in my Android wallpaper apps. Please move to the new generation of the SDK, it said; the old one will eventually stop serving.
That same night I added the migration agent skill Google publishes to my project. A single SKILL.md holds the import mappings, the class and method replacement tables, and a migration checklist. With that in place, asking Claude Code to "migrate this" would have carried the rewrite a long way.
Yet when I finished writing the migration plan, the decision I had reached was: not in the next release. As of late November, both apps are still on the old generation.
The short version
What I most want to pass on is this: a migration skill knows how to rewrite, not when, how much, or in what order to ship. Only someone who knows the app's circumstances can decide the second half.
As an indie developer, here is what I settled on:
Never stack the ads SDK swap onto a release that already carries other changes
Ship the smaller app (my ukiyo-e wallpaper app) first, watch it for a few weeks, then move the main app
Move callbacks that arrive on a background thread onto the main thread once, at the entrance of the ad wrapper layer — not at each call site
The third one departs from what the skill tells you. Most of this piece is about why, and how I then scoped what Claude Code was allowed to do.
The skill does the rewriting; the shipping order and the fences are mine. Setting that line first meant that no matter how fast the agent rewrote things, I wasn't pushed around by the fear of touching the part of the app that pays for it.
Checking the deadline, then deciding not to hurry
The deadlines first. When I checked Google's deprecation and sunset pages in August, they read like this:
SDK
Deprecated
Sunset (ads may stop filling)
Legacy (play-services-ads 25.x)
2027-06-30
2028-06-30
Next-Gen SDK 1.x
Q1 2028
Q2 2029
Nearly two years until sunset. At the same time, the legacy SDK is already in maintenance mode, and new ad formats only land in the new generation. No reason to rush, but a deadline that will corner you if ignored.
The one thing I wanted to avoid was touching the revenue core in a panic right before the cutoff. So I planned backwards and left more than a year of slack.
The other reason was that my unreleased build already carried a pile of changes: a raised minimum OS, an app-open ad fix, a new icon, theme work. Adding a full SDK swap on top would make it impossible to tell which change caused a crash or a drop in show rate. For a one-person shop, a bug you can't isolate is the kind that keeps you up at night.
✦
Thank you for reading this far.
Continue Reading
What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.
WHAT YOU'LL LEARN
✦You will be able to inventory, in your own code, where ad callbacks touch the UI before you hand the rewrite to a migration skill
✦You can prevent the release-day crash where a pick-the-sites migration misses the most dangerous call chain
✦You will be able to fence, with a hook, exactly what Claude Code may rewrite while you are on the migration branch
Secure payment via Stripe · Cancel anytime
✦
Unlock This Article
Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.
The biggest change in the new SDK is that ad loading and event callbacks arrive on a background thread. The legacy SDK called back on the main thread, so my code assumes it can touch Views inside callbacks. Migrate as-is and the first visibility change throws CalledFromWrongThreadException.
The skill's SKILL.md marks this as MANDATORY: wrap every UI-related operation inside each callback in runOnUiThread {} or Dispatchers.Main.launch {}.
Following that literally means opening each callback and wrapping the lines that touch the UI. I didn't.
In my setup, everything ad-related lives in one wrapper package, and the app only receives results through that wrapper's listeners. There are nine caller files per app — eighteen across the two apps. Scattering runOnUiThread there would spread the review across the whole app.
Moving to main once at the wrapper's entrance leaves every caller untouched and keeps the change inside the wrapper package. Still, I wasn't confident the choice was right until I had actually counted.
I wrote an inventory scanner, and the shallow version dropped the most dangerous chains
My August plan had a hand-counted table of eleven places that needed to move to main. The code has been patched since, and even the set of files in the wrapper layer is different now. Going into a migration on the strength of an old hand count felt risky, so I recounted with a script.
The script below reads the Java files in the wrapper layer and lists the places where an SDK callback body appears to touch the UI. It only reads; it writes nothing.
#!/usr/bin/env python3"""Inventory the places where SDK callbacks touch the UI (read-only).usage: python3 callback_ui_audit.py <ad wrapper directory>"""import reimport sysfrom pathlib import Path# Callback names the legacy SDK used to invoke on the main threadCALLBACKS = re.compile( r'\b(onAdLoaded|onAdFailedToLoad|onAdDismissedFullScreenContent|' r'onAdFailedToShowFullScreenContent|onAdShowedFullScreenContent|' r'onUserEarnedReward|onAdImpression|onAdClicked|onAdOpened|onAdClosed)\s*\([^)]*\)\s*\{')# Things that must run on the UI thread, or that propagate to callersUI_HINTS = { 'view': re.compile(r'\.(setVisibility|requestLayout|addView|removeView|removeAllViews|setLayoutParams)\('), 'lookup': re.compile(r'\b(findViewById|hasWindowFocus)\('), 'show': re.compile(r'\.show\('), 'toast': re.compile(r'\bToast\.'), 'propagate': re.compile(r'\b(m?[Ll]istener|mCallback|callback)\.\w+\('),}# Treat the reward lambda passed to show(activity, item -> { ... }) as a callback tooREWARD_LAMBDA = re.compile(r'\.show\(\s*\w+\s*,\s*\w+\s*->\s*\{')METHOD_DEF = re.compile(r'\b(?:private|protected|public|static|final|\s)+[\w<>\[\]]+\s+(\w+)\s*\([^)]*\)\s*\{')MAX_DEPTH = 3# Count as "already on main" only when the body posts to main first (a postDelayed halfway through does not count)FIRST_IS_POST = re.compile(r'\{\s*(?://[^\n]*\s*)*(\w+\.)?(runOnUiThread|post|MAIN\.post)\(')CALL = re.compile(r'\b(\w+)\s*\(')def body_at(src, start): """start is the index of '{'. Return up to the matching '}' (strings and comments are roughly ignored).""" depth = 0 for i in range(start, len(src)): c = src[i] if c == '{': depth += 1 elif c == '}': depth -= 1 if depth == 0: return src[start:i + 1] return src[start:]def audit(root): rows = [] for path in sorted(Path(root).rglob('*.java')): src = path.read_text(encoding='utf-8', errors='replace') methods = {d.group(1): body_at(src, d.end() - 1) for d in METHOD_DEF.finditer(src)} found = [(m, m.group(1)) for m in CALLBACKS.finditer(src)] found += [(m, 'reward-lambda') for m in REWARD_LAMBDA.finditer(src)] for m, cb in found: body = body_at(src, m.end() - 1) guarded = bool(FIRST_IS_POST.match(body)) # Follow methods in the same file up to MAX_DEPTH levels (to catch indirect UI chains) seen, frontier = set(), [body] for _ in range(MAX_DEPTH): nxt = [] for b in frontier: for c in set(CALL.findall(b)): if c in methods and c not in seen: seen.add(c) nxt.append(methods[c]) body += ''.join(nxt) frontier = nxt line = src.count('\n', 0, m.start()) + 1 hits = sorted(k for k, rx in UI_HINTS.items() if rx.search(body)) if not hits: continue rows.append((path.name, line, cb, ','.join(hits), guarded)) return rowsif __name__ == '__main__': if len(sys.argv) != 2 or not Path(sys.argv[1]).is_dir(): sys.exit('usage: callback_ui_audit.py <dir>') rows = audit(sys.argv[1]) for name, line, cb, hits, guarded in rows: mark = 'on-main' if guarded else 'MOVE' print(f'{mark}\t{name}:{line}\t{cb}\t{hits}') need = sum(1 for r in rows if not r[4]) print(f'# callbacks touching UI: {len(rows)} / not yet on main: {need}') sys.exit(1 if need else 0)
What you see is the third version. The two before it are what changed my mind.
Version
How far it follows
Result (wallpaper app wrapper layer)
1st
Callback bodies only
13 sites — but two whole paths were missing: the app-open ad's load-complete path and the reward lambdas
2nd
One level into same-file methods
15 sites. The reward lambdas showed up; the app-open ad still did not. Three sites were also reported as "already on main"
3rd
Three levels, stricter "already on main" rule
21 of 23 callbacks plus 2 reward lambdas need moving; zero already on main
The two paths the first version missed were exactly the ones my August plan had marked highest and high risk. The app-open ad's load callback calls a method that drains a pending cold-start show, which calls another method, which finally puts the ad on screen. The callback body itself has no UI line in it, so a shallow scan sails past. The reward path delivers the reward inside a lambda passed to show(), which then hides the banner and rebuilds the layout. It isn't a named callback, so my first regex never matched it.
The "already on main" results in the second version were a misread. The load-failure callback hides the view first, then schedules a retry with postDelayed. Because the rule treated any post anywhere in the body as safe, it was reporting a direct background-thread setVisibility call as fine.
When I followed three levels deep, nearly everything lit up. That settled it for me.
A migration that only wraps the sites you found crashes on the one site you missed. And the scanner can't promise how deep is deep enough. So rather than choosing sites, it is safer to move everything to main at the entrance. The scanner became evidence for that decision and a check to run after the migration — not a tool for choosing where to fix.
Moving to main once, at the entrance
What happens at the entrance is simple: wrap the listener the caller hands in, so that whichever thread invokes it, it runs on main. On Android you just post to new Handler(Looper.getMainLooper()); here is a version that uses a single-thread executor as a stand-in for main, so you can check the behavior without a device.
import java.util.concurrent.*;/** Move SDK callbacks to the main thread once, at the entrance of the wrapper layer. */public class MainThreadListener { /** The interface callers implement (unchanged from the legacy days) */ interface AdListener { void onLoaded(); void onDismissed(); } /** On Android this is new Handler(Looper.getMainLooper()) */ static final ExecutorService MAIN = Executors.newSingleThreadExecutor(r -> new Thread(r, "main")); /** Wrap the caller's listener so it always runs on main, whichever thread calls it */ static AdListener onMain(AdListener target) { return new AdListener() { @Override public void onLoaded() { MAIN.execute(target::onLoaded); } @Override public void onDismissed() { MAIN.execute(target::onDismissed); } }; } public static void main(String[] args) throws Exception { AdListener caller = new AdListener() { @Override public void onLoaded() { check("onLoaded"); } @Override public void onDismissed() { check("onDismissed"); } void check(String name) { String t = Thread.currentThread().getName(); // On Android this is where Views get touched. Off main: CalledFromWrongThreadException System.out.println(name + " ran on " + t + (t.equals("main") ? " OK" : " NG")); } }; ExecutorService sdkThread = Executors.newSingleThreadExecutor(r -> new Thread(r, "sdk-bg")); System.out.println("-- without wrapper"); sdkThread.submit(caller::onLoaded).get(); System.out.println("-- with wrapper"); AdListener wrapped = onMain(caller); sdkThread.submit(wrapped::onLoaded).get(); sdkThread.submit(wrapped::onDismissed).get(); sdkThread.shutdown(); MAIN.shutdown(); MAIN.awaitTermination(2, TimeUnit.SECONDS); }}
Running it with java MainThreadListener.java on JDK 11:
-- without wrapperonLoaded ran on sdk-bg NG-- with wrapperonLoaded ran on main OKonDismissed ran on main OK
Three reasons for wrapping at the wrapper rather than at the callers:
The caller-facing interface stays exactly as it was in the legacy days, so the eighteen app-side files have a zero-line diff
My real wrappers already hold a new Handler(Looper.getMainLooper()) for retries. Using the same idiom means I won't hesitate when I reread it
After the migration, rerunning the scanner only has to answer one question: was the entrance wrapped? No per-site judgment needed
One trade-off to accept: wrapping pushes the work back by however long main's queue takes. My reward grant is paired with a minimum-watch-time check that compares timestamps, so which thread takes that timestamp stays on my list to verify during the migration. That's something the scanner can't tell you.
On the migration branch, a hook fences what Claude Code may rewrite
Even with the approach decided, an agent doing the rewrite will sometimes want to fix the callers instead — all the more so when the skill says "wrap inside each callback." So while I'm on the migration branch, a PreToolUse hook blocks writes outside the wrapper layer.
#!/usr/bin/env bash# PreToolUse hook: while on the migration branch, block writes outside the ad wrapper layer.# Intended for a .claude/settings.json matcher of "Edit|Write|MultiEdit".set -euo pipefailALLOW_DIR="app/src/main/java/com/example/ads/" # the only place that may be rewrittenALLOW_EXTRA='(^|/)(build\.gradle(\.kts)?|proguard-rules\.pro|AdsConfig\.java|AdsInitializer\.java)$' # exceptions: dependencies, shrinker rules, App ID constant, initializationinput="$(cat)"file="$(printf '%s' "$input" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("tool_input",{}).get("file_path",""))')"cwd="$(printf '%s' "$input" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("cwd","."))')"branch="$(git -C "$cwd" rev-parse --abbrev-ref HEAD 2>/dev/null || echo none)"[[ "$branch" == feature/gma-next-gen* ]] || exit 0 # do nothing outside the migration branch[[ -z "$file" ]] && exit 0rel="${file#"$cwd"/}"if [[ "$rel" == "$ALLOW_DIR"* ]] || [[ "$rel" =~ $ALLOW_EXTRA ]]; then exit 0fiecho "On the migration branch, nothing outside ${ALLOW_DIR} gets rewritten: ${rel}. If you want to change a caller, first check whether the wrapper can move the call to main instead." >&2exit 2
I fed the hook hand-built JSON on both the migration branch and main:
Branch
Target
Exit code
feature/gma-next-gen-ue
Banner in the wrapper layer
0 (allow)
feature/gma-next-gen-ue
Gallery screen (a caller)
2 (block with reason)
feature/gma-next-gen-ue
build.gradle, proguard-rules.pro, initializer class
0 (allowed exceptions)
feature/gma-next-gen-ue
AndroidManifest.xml
2 (block)
main
Gallery screen (a caller)
0 (hook does nothing)
Blocking the manifest is deliberate. The new SDK takes the App ID in code, but the consent SDK still needs the manifest entry. An agent deciding "this isn't needed anymore" and deleting it is the change I fear most, so during the migration it sits out of reach. The four exceptions match what my plan listed as changing outside the wrapper: dependencies, shrinker rules, the App ID, and initialization.
The message the hook prints on a block goes straight back to Claude Code. Returning a next step — "see whether the wrapper can move this to main" — rather than a bare refusal tends to steer the agent's next proposal back in a sensible direction.
Pitfalls
Reading a mid-body postDelayed as "already on main"
This is the one the second scan version stepped on. A single post in a callback body makes it look safe, but it means nothing if a line before it touched a View. I now count a callback as safe only when it hands its whole body to main up front. The same trap exists when a person reviews by eye, so it's on my review list too.
Shallow scans drop the most dangerous chains first
For both the app-open ad and the reward, the dangerous operation sat two or three calls past the callback. Risky work tends to live behind other condition checks, which is exactly what shallow scans are bad at. When the scanner reports a suspiciously small count, I've learned to distrust it.
The skill landed in two places, and the copies didn't match
After installing the skill, I found it had been written to a new folder in addition to my usual skills directory, and a new lockfile had appeared at the project root. The two SKILL.md files differ only in how their frontmatter is formatted, but their bytes don't match. The existing lock lists 41 skills, the new one lists only this one, and five skills appear in neither. It's worth checking, on install day, which tool reads which location. I wrote up a scan for same-named skills in two places in the case where one copy of a skill had quietly lost files.
Working in debug proves nothing
I once hit a bug where the shrinker removed a reflection target, so the app worked in debug and failed silently only in release. The ads SDK changes its package name entirely, so keep rules need a fresh look too. Verification happens only on release builds on real devices; I put that at the top of the plan.
There's no off-switch for crashes outside the app
I can soften ad frequency with a server-side value, but the SDK is compiled into the app, so a crash can't be stopped from the server. The only real exit is the staged rollout. Halt at 10% if anything looks wrong; keep the previous AAB ready to republish; do the work on a dedicated branch and merge to main only after verification. I decided all three before writing any code.
What I finally decided
The order: ship the smaller app first, watch it for a few weeks, then move the main wallpaper app. One app is the source of truth and the other is generated from it by a sync script, and the wrapper layer barely differs between them, so whatever the first app teaches carries straight over.
In October two more emails came — one urging the migration, one suggesting a larger banner format available only in the new SDK. But I was in the middle of a test that turns off the paywall screen, and changing the ad foundation then would have made the results impossible to separate. Starting only after that test concludes is a call I've kept.
The migration skill really is a strong ally when it comes to rewriting speed. But precisely because the rewrite can be fast, the shipping order and the fences had to be decided by me first. On the night I installed it, I really did think I could migrate the next day; as the plan grew, my hands slowed, and this piece is those reasons put into words one at a time.
If you have the same migration ahead, I'd suggest running the scanner above against your own wrapper layer once before you ask the skill for anything. If the count comes back small, add one more level of depth and run it again. The difference between the two runs is the size of what you would have missed.
Share
Thank You for Reading
Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.