Android Packaging
This document outlines the process of packaging Flet applications for Android, generating both APK and Android App Bundle (AAB) formats.
Prerequisites
$HOME/java/{version}.$HOME/Android/sdk.numpy, cryptography) have pre-built wheels available for Android.Build Commands
flet build apk**arm64-v8a, armeabi-v7a).
* Configuration: `[tool.flet.android]
split_per_abi = true or flet build apk --split-per-abi`.
* Note: Distribute the correct APK for the user's device architecture.
* **Installing APK to a device:** Use the Android Debug Bridge (adb).
* Command: adb install .
* Specify device: adb -s install (use adb devices to list devices).flet build aab**Signing an Android Bundle
Android requires all APKs to be digitally signed. For AABs, you sign with an upload key, and Google Play handles app signing. For APKs distributed elsewhere, you must manually sign.
keytool.keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
* Windows (PowerShell): keytool -genkey -v -keystore $env:USERPROFILE\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
* Remember the keystore password and alias. Keep the keystore file private.
* Note: keytool is part of the JDK. If not in PATH, use the full path (e.g., from flutter doctor -v). Use -storetype JKS for Java 9+.flet build aab --android-signing-key-alias or pyproject.toml: `[tool.flet.android.signing]
key_alias = "value" or Environment Variable: FLET_ANDROID_SIGNING_KEY_ALIAS="value"`.
* **Key Store:** flet build aab --android-signing-key-store or pyproject.toml: `[tool.flet.android.signing]
key_store = "path/to/store.jks"`.
* **Key Store Password:** flet build aab --android-signing-key-store-password or Environment Variable: FLET_ANDROID_SIGNING_KEY_STORE_PASSWORD="value". (Not read from pyproject.toml for security).
* **Key Password:** flet build aab --android-signing-key-password or Environment Variable: FLET_ANDROID_SIGNING_KEY_PASSWORD="value". (Defaults to key store password if not provided. Not read from pyproject.toml for security).Disable Splash Screen
flet build apk --no-android-splash.pyproject.toml: `[tool.flet.splash]Android Manifest Configuration
Configure elements for AndroidManifest.xml via CLI or pyproject.toml.
flet build apk --android-meta-data name_1=value_1 name_2=value_2
* pyproject.toml: `[tool.flet.android.meta_data]
"name_1" = value_1
"name_2" = value_2`
* Supported value types: String, Integer, Boolean, Float.flet build apk --android-features name_1=required_1 name_2=required_2
* pyproject.toml: `[tool.flet.android.feature]
"name_1" = required_1
"name_2" = required_2`
* required is a boolean (true or false).
* Default features: "android.software.leanback" = False, "android.hardware.touchscreen" = False.flet build --android-permissions permission=True|False ...
* Example: flet build --android-permissions android.permission.READ_EXTERNAL_STORAGE=True android.permission.WRITE_EXTERNAL_STORAGE=True --android-features android.hardware.location.network=False
* pyproject.toml: `[tool.flet.android.permission]
"android.permission.CAMERA" = true`
* Default permissions: android.permission.INTERNET (can be disabled with android.permission.INTERNET=False).ADB Tips
adb shellsu (in adb shell)adb pull
Previous
arrow_back
Publish
Next
arrow_forward