Ask ChatGPT for a single self-contained index.html (CSS and JavaScript inside, data saved with localStorage), save it as index.html, then build it with an HTML to APK maker. The app works offline because the file is inside it.
- Best mode
- HTML to APK
- Files
- One index.html
- Works offline
- Yes
- Coding
- None
The prompt that produces app-ready code
Build a mobile-first habit tracker as ONE self-contained index.html. - All CSS in a <style> tag and all JavaScript in a <script> tag - No external libraries, fonts or images (use emoji/SVG) - Save data with localStorage so it survives closing the app - Include <meta name="viewport" content="width=device-width, initial-scale=1"> - Large touch targets (at least 48px), no hover-only features
Each line prevents a common failure: external files that don't get saved, missing viewport (tiny text), data lost on restart, buttons too small for thumbs.
From chat to APK on one phone
- Copy the codeUse the copy button on the code block.
- Save it as index.htmlPaste into any text editor app and save as
index.html— or let the HTML to APK app create the file from pasted code if it offers that. - Preview itOpen the file in Chrome to make sure it runs.
- BuildHTML to APK → pick index.html → app name, icon → build → install.
When the AI's code needs a fix
| Symptom | Likely cause | Ask the AI |
|---|---|---|
| Blank screen | JavaScript error | "Fix any errors; it shows a blank page on Android" |
| Data disappears | No storage | "Persist all state in localStorage" |
| Fonts/icons missing offline | CDN links | "Remove all external resources" |
| Tiny page | No viewport tag | "Add a mobile viewport meta tag" |
Multi-file projects (React, Vite) generated by AI tools need a build first — see the base-path fix.
Questions people ask
Can ChatGPT make the APK itself?
No. It writes code; an Android build tool has to compile and sign it. Why, and the workaround.
Is it allowed to publish an AI-written app on Google Play?
Yes, if it follows Play policies. You're responsible for what it does and its privacy disclosures.