This example demonstrates a complete native Android activity written entirely in Swift. It showcases Android integration including OpenGL ES rendering, native app lifecycle management, and the Android Native App Glue framework.
The project consists of:
- Native Activity: A complete Swift implementation that creates an OpenGL ES context and renders a continuously changing colored background.
- Android Native App Glue: Uses the Android Native App Glue framework to handle Android lifecycle and integrates with Choreographer for smooth rendering at 60fps.
Before you can build and run this project, you need to have the following installed:
- Java Development Kit (JDK): We recommend using JDK 25. Ensure the
JAVA_HOMEenvironment variable is set to your JDK installation path. - Swiftly: You need to install Swiftly
- Swift SDK for Android: You need to install the Swift SDK for Android
- Device/emulator with OpenGL ES support
-
Open the
swift-android-examplesproject in Android Studio. -
Select the
native-activityGradle target. -
Run the app on an Android emulator or a physical device.
# Build the example
./gradlew :native-activity:assembleDebug
# Install on device/emulator
./gradlew :native-activity:installDebug