Building an Android APK¶
A mobile project (target Mobile (Flet)) builds into an APK, the file Android installs apps from. Whittl does the whole build itself: no Android Studio, JDK, Gradle or Flutter on your computer.
Start with Mobile Apps (Flet) if you have not made a mobile project yet.
Build the APK¶
- Save the project (Whittl builds from the project folder).
- Pick the right device format beside the Target dropdown. It decides which phones the APK installs on: Flip phone (32-bit) builds for 32-bit Android Go phones, every other format for 64-bit phones and tablets.
- Click Download (or press F3). On a mobile project this builds an APK instead of a desktop installer.
What happens next, in order:
APK Build Tools Required. The first build, and the first build of a new kind of app, shows what is missing and offers Install && Continue:
- an APK template, downloaded once per kind (Flet 1.0: about 24-31 MB each; Flet 0.28: about 64 MB). Templates are checked against a fingerprint before use and kept in
~/.whittl/templates. - the signing tools, if they are missing (the installed Whittl includes them)
- ADB, Google's tool for installing on a phone over USB, kept in
~/.whittl/platform-tools
Phone plugged in. If a phone is connected over USB with USB debugging on and it cannot run the type you chose (a 32-bit phone with Phone selected, for example), Whittl offers to build this APK for that phone's type. The device menu stays as it was.
Build for Android. The settings for this app:
- Name: shown under the icon on the phone, up to 19 characters.
- Package ID:
com.yourname.appname, up to 28 characters. Keep it the same between builds so the phone updates the app instead of installing a second copy. - Icon: choose a picture, or Generate... one with image generation. A project with an icon file uses it by default.
- Splash (Flet 1.0): what the phone shows while the app starts. Built with Whittl (the default), App icon, Your image, or None. Android 12 and newer show a round icon only. Whittl remembers the choice for the project. Flet 0.28 apps keep Flet's own splash.
Then pick where to save the APK (your Downloads folder by default).
Checks before the build. Whittl stops to ask when it finds something that will break on the phone:
- Pictures the phone won't find. On a phone, Flet looks for pictures inside the project's
assets/folder, so a path is written from there:"icons/play.png", not"assets/icons/play.png". Whittl lists each file and line. Ask the AI to fix the paths, or Build anyway. - Won't run on Android (Flet 0.28 only). The app imports a package that cannot run on Android, so the APK would close as soon as it opens.
APK Built Successfully shows the file's location and size, and any package that could not be added.
Install it on a phone¶
Over USB¶
- On the phone, turn on Developer options (Settings > About phone, tap Build number seven times).
- Turn on USB debugging in Developer options.
- Plug the phone in and accept the Allow USB debugging? prompt on the phone.
- In the APK Built Successfully window, Whittl shows Device detected with the phone's model. Click Install to (the model). If the phone was plugged in late, click Retry detection.
If an older build of the app with a different signature is on the phone, Whittl removes it and installs again. Open the app from the phone's app list.
By copying the file¶
Copy the APK to the phone (USB, cloud storage, email), tap it, and allow installs from that source when Android asks.
Google Play¶
Not yet. Play needs an app bundle (AAB) and its own signing setup; it is planned for a later version.
Which template an app gets¶
Whittl picks the smallest template that carries every Flet extension the app imports:
| Template | Carries |
|---|---|
| standard | charts, audio, geolocation, permission handling |
| camera | the standard ones plus the camera |
| media | the standard ones plus video |
Each has a 64-bit and a 32-bit version. An app that imports both the camera and video cannot be built yet; Whittl says so before the build. An extension imported inside a try (so the desktop runs without it) still counts when a template carries it.
The Flet 1.0 templates declare the permissions an app may ask for: storage and media (photos, audio, video), the microphone, location, vibration, notifications and Bluetooth; the camera template adds the camera. The phone asks the user only when the app requests one.
Packages¶
On Flet 1.0, the build adds the packages the app uses:
- Packages it imports, and packages named on a
# REQUIRES:line in the code. - Packages with compiled parts (Pillow, NumPy, pandas and others) come from Flet's Android package index,
pypi.flet.dev; pure-Python packages come from PyPI. - A package with no Android build anywhere is left out, and APK Built Successfully says so: the app will close when it imports it. Ask the AI to do without it. When the app imports that package only inside a
try(with a fallback), the window says the app runs without it instead; check the part that uses it.
Flet itself and its extensions come from the template, never from your code.
Your project's files go in too: everything beside main.py, including the assets/ and data/ folders (a word list or starter database the app reads), but not archives, build output, virtual environments or hidden files. A file the app saves belongs in Flet's storage folder instead, because the app's own folder is replaced when you install an update; the AI is taught this.
A file the user picks with Flet's file picker is a temporary copy on Android, in the app's cache, and Android can delete it. An app that keeps a list of picked files (songs, photos) copies each one into its storage folder and saves that path; the AI is taught this too.
On Flet 0.28, only pure-Python packages work in an APK.
Troubleshooting¶
"No device connected"¶
- Check USB debugging is on, and accept the prompt on the phone.
- On Windows, a phone that Windows does not recognise may need Google's USB driver.
- Try another cable; some only charge.
- Click Retry detection. From the second try, Whittl restarts adb (Android's connection tool) before looking, which clears a connection that has stopped answering. It also does this at once when adb reports it is broken.
"Wrong phone type"¶
The APK was built for the other kind of phone. Choose Phone in the device menu for a 64-bit phone, or Flip phone (32-bit) for a 32-bit one, and build again. With the phone plugged in before the build, Whittl offers this itself.
The app installs but closes at once¶
- A package it imports is not in the APK. APK Built Successfully lists those.
- A picture or file path points outside
assets/. - On Flet 0.28, a package with compiled parts (Pillow, NumPy) cannot run.
- A file it saved the path of was a file-picker copy that Android has since deleted (the log shows
FileNotFoundException ... cache/file_picker/...). See Packages.
To read the error, connect the phone and run adb logcat from ~/.whittl/platform-tools; the Python traceback is in the log.
It runs on the phone but not in an Android emulator¶
A Flet 1.0 APK is built for the ARM processors in phones and tablets. An Android emulator on a PC usually runs an x86_64 system image and runs ARM apps through translation, and there a Flet 1.0 app stops as it starts (in adb logcat: dlopen failed: library "./lib_ctypes.so" not found). Test a Flet 1.0 APK on a phone or tablet. A Flet 0.28 APK also carries x86_64 and runs in the emulator.
The phone shows "App not installed"¶
Usually an older build with a different signature. Uninstall the app on the phone and install again, or keep the same Package ID and let Whittl replace it.
The build says "No Android template carries ..."¶
The app imports a Flet extension none of the templates has (for example the camera and video together). The app still runs on your computer.
What's next¶
- Mobile Apps (Flet)
- Moving a Project to Flet 1.0
- Building an Installer, for desktop apps