Android Platform
Build and deploy GreenhouseAdmin as a native Android application. This guide covers development setup, building APKs, and Android-specific configuration.Overview
The Android platform uses:- Target SDK: 36 (Android 15)
- Minimum SDK: 24 (Android 7.0 Nougat)
- Compile SDK: 36
- JVM Target: Java 11
- HTTP Engine: OkHttp (Ktor client)
The minimum SDK 24 ensures compatibility with 95%+ of Android devices in the market.
Prerequisites
Install Android SDK
Install Android Studio or Android command-line tools:
- Android Studio: Download
- Command-line tools: SDK Manager
- Android SDK Platform 36
- Android SDK Build-Tools 34.0.0+
- Android SDK Platform-Tools
Configuration
Android-Specific Dependencies
The Android platform uses the OkHttp engine for Ktor networking:composeApp/build.gradle.kts
Application Configuration
composeApp/build.gradle.kts
Dependency Injection (Koin)
Android requires platform-specific Koin initialization in the Application class:androidMain/.../GreenhouseApplication.kt
AndroidManifest.xml:
Development
Running on Emulator/Device
- Android Studio
- Command Line
Viewing Logs
Monitor application logs with Logcat:Building APKs
Debug Build
Build a debug APK for development:composeApp/build/outputs/apk/debug/composeApp-debug.apk
Release Build
Build a release APK for production:Configure Signing
Create Add to
keystore.properties in the project root:keystore.properties
.gitignore:Android App Bundle (AAB)
Build an Android App Bundle for Google Play Store distribution:composeApp/build/outputs/bundle/release/composeApp-release.aab
Google Play Store requires AAB format for new app submissions.
Android-Specific Features
Activity Compose Integration
The Android app uses Jetpack Compose withactivity-compose:
androidMain/.../MainActivity.kt
Permissions
For network access, declare inAndroidManifest.xml:
ProGuard/R8
For release builds with code shrinking, createproguard-rules.pro:
composeApp/proguard-rules.pro
Testing
Emulator Setup
Create an emulator for testing:Device Testing
Connect a physical device:Troubleshooting
ANDROID_HOME not set
ANDROID_HOME not set
Error:
SDK location not foundSolution: Set the ANDROID_HOME environment variable or create local.properties:Device not detected
Device not detected
Error: No devices shown in
adb devicesSolution:- Enable USB debugging on device
- Try different USB cable/port
- Restart adb server:
Build fails with dex errors
Build fails with dex errors
Error:
Cannot fit requested classes in a single dex fileSolution: Enable multidex in build.gradle.kts:OkHttp SSL errors
OkHttp SSL errors
Error:
SSLHandshakeExceptionSolution: Ensure your API uses a valid SSL certificate. For development with self-signed certificates, you may need to add network security configuration.Next Steps
iOS Platform
Build and deploy to iOS devices
Web Platform
Deploy as a web application
Architecture
Understand MVVM architecture and DI
Building
Build for all platforms