This guide will help you set up your development environment for the GreenhouseAdmin project, a Kotlin Multiplatform application targeting Web (Wasm/JS), Android, iOS, and Desktop (JVM).
Prerequisites
Before you begin, ensure you have the following installed:
Java Development Kit (JDK) 21
Download and install JDK 21 from Adoptium or Oracle . Verify installation: java -version
# Should show version 21.x.x
Android SDK (for Android builds)
Install Android SDK through Android Studio or standalone command-line tools. Required SDK components:
Android SDK Platform 36 (compileSdk)
Android SDK Build-Tools
Android SDK Platform-Tools
Set ANDROID_HOME environment variable: # macOS/Linux
export ANDROID_HOME = $HOME / Library / Android / sdk
export PATH = $PATH : $ANDROID_HOME / tools : $ANDROID_HOME / platform-tools
# Windows
setx ANDROID_HOME "%LOCALAPPDATA%\Android\Sdk"
Xcode (for iOS builds - macOS only)
Install Xcode from the Mac App Store. After installation, accept the license and install command-line tools: sudo xcodebuild -license accept
xcode-select --install
Git
Install Git from git-scm.com or use your system’s package manager. # macOS
brew install git
# Ubuntu/Debian
sudo apt-get install git
# Windows
# Download installer from git-scm.com
Cloning the Repository
Clone the GreenhouseAdmin repository to your local machine:
git clone < repository-ur l >
cd GreenhouseAdmin
Project Configuration
Environment Variables
The project uses local.properties to configure environment-specific settings. This file is gitignored and must be created locally.
Never commit local.properties to version control. It may contain sensitive API URLs and keys.
Create local.properties in the project root:
# local.properties
API_BASE_URL =https://api-dev.example.com/api/v1/
The API_BASE_URL should include the full path including /api/v1/ suffix. This value is injected into the application via BuildKonfig at compile time.
Gradle Configuration
The project comes with pre-configured Gradle settings in gradle.properties:
# Kotlin
kotlin.code.style =official
kotlin.daemon.jvmargs =-Xmx4092M
# Gradle
org.gradle.jvmargs =-Xmx4096M - Dfile.encoding =UTF-8
org.gradle.configuration-cache =true
org.gradle.caching =true
# Android
android.nonTransitiveRClass =true
android.useAndroidX =true
These settings allocate 4GB RAM to Gradle and the Kotlin daemon. Adjust if needed based on your system resources.
Installing Dependencies
The project uses Gradle wrapper, so no global Gradle installation is required.
First-Time Setup
Run the following commands to download dependencies and set up the project:
# Make gradlew executable
chmod +x gradlew
# Sync dependencies
./gradlew --refresh-dependencies
Yarn Lock Files (Important for Web targets)
After any dependency changes, you must upgrade Yarn lock files for JavaScript and WebAssembly targets:
./gradlew kotlinUpgradeYarnLock # JS target
./gradlew kotlinWasmUpgradeYarnLock # Wasm target
Failing to upgrade Yarn lock files after dependency changes will cause build failures for Web targets.
IDE Setup
The recommended IDEs for Kotlin Multiplatform development are:
IntelliJ IDEA (Recommended)
Download IntelliJ IDEA (Community or Ultimate)
Open the project by selecting the root directory
IntelliJ will automatically detect it as a Gradle project
Wait for Gradle sync to complete
Install recommended plugins if prompted:
Kotlin Multiplatform
Compose Multiplatform
Android Studio
Download Android Studio
Open the project by selecting the root directory
Ensure the Kotlin Multiplatform plugin is installed:
Go to Settings → Plugins
Search for “Kotlin Multiplatform”
Install if not already installed
Wait for Gradle sync to complete
Verifying Your Setup
Verify your environment is correctly configured by running a simple build:
# Build all targets
./gradlew build
# Or build specific target
./gradlew :composeApp:wasmJsBrowserDevelopmentRun
If the build succeeds, your environment is ready for development!
Project Structure Overview
Understand the project structure before you start coding:
GreenhouseAdmin/
├── composeApp/ # Main application module
│ ├── src/
│ │ ├── commonMain/ # Shared code (all platforms)
│ │ ├── androidMain/ # Android-specific code
│ │ ├── iosMain/ # iOS-specific code
│ │ ├── jvmMain/ # Desktop-specific code
│ │ ├── jsMain/ # JavaScript target code
│ │ ├── wasmJsMain/ # WebAssembly target code
│ │ └── commonTest/ # Shared tests
│ └── build.gradle.kts # Module build configuration
├── gradle/ # Gradle wrapper and version catalog
│ └── libs.versions.toml # Dependency versions
├── build.gradle.kts # Root build configuration
├── local.properties # Local environment config (create this)
└── gradle.properties # Gradle settings
Next Steps
Building Learn how to build for different platforms
Testing Understand the testing structure and best practices
Deployment Deploy your application using Docker and CI/CD
Architecture Explore the MVVM architecture and design patterns
Troubleshooting
Gradle Daemon Issues
If you encounter issues with the Gradle daemon:
# Stop all Gradle daemons
./gradlew --stop
# Clear Gradle cache
rm -rf ~/.gradle/caches/
Dependency Resolution Failures
# Clear dependency cache and refresh
./gradlew clean --refresh-dependencies
Out of Memory Errors
Increase memory allocation in gradle.properties:
org.gradle.jvmargs =-Xmx8192M - Dfile.encoding =UTF-8
kotlin.daemon.jvmargs =-Xmx8192M
iOS Build Failures (macOS)
Ensure Xcode command-line tools are properly configured:
sudo xcode-select --reset
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer