On this page
The most dangerous AI-generated code isn't the code that fails to compile. It's the code that compiles, passes a quick manual test, and fails for 2% of users after rotation, on slow networks or in release builds. Verification has to look exactly where those failures hide.
Verification layers
The checklist
1. Automated
- โ Builds cleanly with no new warnings you don't understand
- โ Lint passes (run
./gradlew lintDebug), and static analysis passes - โ Unit tests added or updated for new logic, and they fail when the logic is broken
2. Understanding
- โ You can explain every line and why it's there
- โ Every API and dependency exists in the versions you use (checked in official docs)
- โ No dead code, unused parameters or leftover placeholder logic
3. Android correctness
- โ No I/O or heavy work on the main thread; no
runBlocking - โ Coroutines in lifecycle-aware scopes;
CancellationExceptionnot swallowed - โ No Activity, View or Context held in ViewModels or singletons
- โ State survives rotation and process death where it matters
- โ Flows collected lifecycle-aware (
collectAsStateWithLifecycle,repeatOnLifecycle) - โ Runtime permissions requested and handled when denied
4. Security and privacy
- โ No API keys, tokens or secrets in code or resources
- โ No logging of personal data or auth headers
- โ No disabled TLS or certificate validation, and no cleartext traffic added
- โ New components not exported unless required; intents validated
- โ Data safety and privacy disclosures still accurate
5. Quality
- โ Content descriptions, 48dp touch targets, sufficient contrast, TalkBack order
- โ Strings in resources; works at large font scale and in dark mode
- โ Lazy lists with keys; no expensive work in composition
- โ Loading, empty and error states handled
6. Release readiness
- โ Tested on a minified release build (R8) to catch reflection and serialization issues
- โ Tested on at least one real, mid-range device
- โ Feature flag or staged rollout for risky changes
Common AI mistakes, caught
// 1. Works until rotation: state in remember instead of saveable/ViewModel
var draft by remember { mutableStateOf("") } // lost on rotation โ rememberSaveable
// 2. Works in debug, crashes in release: reflective JSON without keep rules / codegen
val user = Gson().fromJson(json, User::class.java) // R8 may strip/rename fields
// 3. Works on Wi-Fi, ANRs on slow networks: blocking call in a click listener
button.setOnClickListener { api.syncBlocking() } // move to viewModelScope + suspendAutomate what you can
- CI runs lint, tests and a release build on every PR. See CI/CD with GitHub Actions.
- StrictMode and LeakCanary in debug builds catch threading and leak issues during manual testing.
- Screenshot tests catch visual and accessibility regressions in shared components.
Scaling the checklist
Small UI change
Layers 1, 2 and 5, plus a quick device check.
New data or async logic
All layers, with extra attention to layer 3.
Anything touching auth, payments or personal data
All layers, plus a security-focused review by a second person.
Frequently asked questions
Isn't this checklist the same for human-written code?
Mostly, yes. AI-generated code just makes certain mistakes more often (invented APIs, lifecycle subtleties, generic error handling), and it arrives faster, so applying the checklist consistently matters more.
How long should verification take?
Proportional to risk. Small UI tweaks take minutes. New async or security-relevant logic deserves careful review and tests.
Can another AI verify the code?
AI review can help find issues, but it doesn't replace running the code, tests and human understanding. See AI Code Review.
Conclusion
Verify AI-generated Android code in layers: automated checks, full understanding, Android correctness, security, quality and release readiness on a minified build and a real device. That's how you get AI's speed without shipping its subtle mistakes.
Next step: secure your app more broadly with Android App Security Best Practices.
Official references
๐ฑ Apps built by Yunok Tech
Real Android apps on Google Play, free to download.
Walzi4K wallpapers for lock and home screenGet it โธ
NotiVaultNotification history: recover dismissed notificationsGet it โธ
Ready to build real Android applications?
AI coding tools multiply what you already know. The stronger your Kotlin, Compose and architecture foundation, the better you can judge, fix and ship what these tools suggest.
Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.
Explore the Android course and take your next step as an Android developer.