Installation¶
This guide takes you from a clean Python environment to the Hot Previewer and a native Android build.
Requirements¶
- Python 3.8 or newer;
- a JDK between 17 and 21 for local Android compilation;
- the Android SDK, either from Android Studio or from
apkpy setup.
Install or update ApkPy:
Check the Android toolchain:
If ApkPy cannot find a suitable JDK or Android SDK, let it install a compatible local toolchain:
Create the first project¶
The project contains writehere.py, the source file in which you create screens and app logic.
Replace it with:
from apkpy_lib import Screen, button, label, run, toast
home = Screen(id="home")
label("My first native screen", id="title", screen=home)
button("Test action", command=lambda: toast("It works"), screen=home)
style = """
home {
background-color: #09090B;
padding: 24px;
gap: 16px;
}
title {
color: #FAFAFA;
font-size: 28px;
font-weight: bold;
}
button {
background-color: #8B5CF6;
color: #FFFFFF;
border-radius: 14px;
padding: 14px;
}
"""
if __name__ == "__main__":
run(start_screen=home)
Preview, build or run¶
Use this during interface development. It starts quickly and lets you test navigation, inputs, state and callbacks on your computer.
This creates a ZIP containing the generated Gradle project. Open the extracted project in Android Studio when you want to inspect Java/XML or use Android Studio tooling.
Optional installation helpers:
Start from an example¶
Use the interactive example picker:
Examples cover basic UI, multiple screens, storage, permissions, background work, camera/gallery, dialogs, location, network images, loading, secure login, REST, SQLite lists and Python loops.
Recommended workflow¶
- Build the screen in
writehere.py. - Test the behavior in the Hot Previewer.
- Run
apkpy buildwhen checking generated Android code. - Test on an Android emulator or physical device.
- Run
apkpy releaseonly when the app identity and signing key are ready.
Continue with Core concepts.