Skip to content

Commit e1095cb

Browse files
New flet build settings (Android SDK version, boot/startup screens) (#405)
* Android SDK version settings * Android SDK version settings and app element in manifest * Boot and Startup screens
1 parent 31d9bb8 commit e1095cb

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

docs/publish/android.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,59 @@ Configuring splash in `pyproject.toml`:
9898
android = false
9999
```
100100

101+
## Android SDK version settings
102+
103+
### `min_sdk_version`
104+
105+
* Defines the minimum Android version (API level) your app can run on.
106+
* If a device has a lower version than `min_sdk_version`, your app won’t install or run on that device.
107+
* Increasing this value means dropping support for older devices.
108+
109+
Configuring in `pyproject.toml`:
110+
111+
```toml
112+
[tool.flet.android]
113+
min_sdk_version = 21
114+
```
115+
116+
If `min_sdk_version` = `21`, your app will not install on Android 4.4 (API 19) or lower.
117+
118+
Default is `21`.
119+
120+
### `target_sdk_version`
121+
122+
* Defines the Android version your app is optimized for.
123+
* Your app can run on higher Android versions but will behave as if it’s running on `targetSdkVersion` unless explicitly adapted.
124+
* Google Play requires you to update this regularly to meet new Android requirements.
125+
126+
Configuring in `pyproject.toml`:
127+
128+
```toml
129+
[tool.flet.android]
130+
target_sdk_version = 34
131+
```
132+
133+
If `targetSdkVersion` = `34`, your app will run on Android 14 and above with the latest system behaviors. On newer Android versions, some strict security and API changes may apply automatically.
134+
135+
Default `target_sdk_version` is `35`.
136+
137+
#### Key differences
138+
139+
| Feature | `min_sdk_version` | `target_sdk_version` |
140+
|------------------|-----------------|------------------|
141+
| Defines... | **Minimum Android version** required to install & run the app | **Optimized Android version** for best compatibility |
142+
| Impact | Lowering it allows **more devices** to install the app | Raising it allows access to **newer Android features** |
143+
| If set too low | App may not support modern APIs & security | App might not follow latest Android restrictions |
144+
| If set too high | App won't install on older devices | No major downside (except adapting to new behaviors) |
145+
146+
Configuring both settings in `pyproject.toml`:
147+
148+
```toml
149+
[tool.flet.android]
150+
min_sdk_version = 21
151+
target_sdk_version = 34
152+
```
153+
101154
## Permissions
102155

103156
Configuring Android permissions and features to be written into `AndroidManifest.xml`:
@@ -177,6 +230,16 @@ host = "mydomain.com"
177230

178231
See [Deep linking](https://docs.flutter.dev/ui/navigation/deep-linking) section in Flutter docs for more information and complete setup guide.
179232

233+
## Manifest application element properties
234+
235+
Adding custom properties to `<application>` element in `AndroidManifest.xml`:
236+
237+
```toml
238+
[tool.flet.android.manifest_application]
239+
usesCleartextTraffic = "true"
240+
requestLegacyExternalStorage = "true"
241+
```
242+
180243
## Troubleshooting Android
181244

182245
To run interactive commands inside simulator or device:

docs/publish/index.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,46 @@ ios = false # --no-ios-splash
210210
android = false # --no-android-splash
211211
```
212212

213+
## Boot screen
214+
215+
Boot screen is shown while the archive with Python app is being unpacked to a device file system.
216+
It's shown after splash screen and before startup screen. App archive does not include 3rd-party site packages.
217+
If the archive is small and its unpacking is fast you can keep that screen disabled (default).
218+
219+
To enable boot screen in `pyproject.toml` for all target platforms:
220+
221+
```toml
222+
[tool.flet.app.boot_screen]
223+
show = true
224+
message = "Preparing the app for its first launch…"
225+
```
226+
227+
Boot screen can be enabled for specific platforms only or its message customized. For example, enabling it for Android only:
228+
229+
```toml
230+
[tool.flet.android.app.boot_screen]
231+
show = true
232+
```
233+
234+
## Startup screen
235+
236+
Startup screen is shown while the archive with 3rd-party site packages (Android only) is being unpacked and Python app is starting. Startup screen is shown after boot screen.
237+
238+
To enable startup screen in `pyproject.toml` for all target platforms:
239+
240+
```toml
241+
[tool.flet.app.startup_screen]
242+
show = true
243+
message = "Starting up the app…"
244+
```
245+
246+
Startup screen can be enabled for specific platforms only or its message customized. For example, enabling it for Android only:
247+
248+
```toml
249+
[tool.flet.android.app.startup_screen]
250+
show = true
251+
```
252+
213253
## Entry point
214254

215255
By default, `flet build` command assumes `main.py` as the entry point of your Flet application, i.e. the file with `ft.app(main)` at the end. A different entry point could be specified with `--module-name` argument or in `pyproject.toml`:

0 commit comments

Comments
 (0)