Android Development?If you’re building Android applications, see the Kotlin (Android) documentation instead, which includes Android-specific guidance for Gradle Android plugin, Android engines, and AARs.
Supported Platforms
- JVM: Java 8+ and Kotlin 1.5+
- Server Applications: Ktor, Spring Boot, Micronaut, Quarkus
- CLI Tools: Command-line applications and scripts
- Worker Processes: Background jobs and data processing
- Microservices: Containerized applications and serverless functions
Installation
Add the GrowthBook JVM SDK and a network dispatcher to your project:Quick Start
Here’s a minimal example to get started with the GrowthBook Kotlin JVM SDK:Network Dispatchers
The GrowthBook SDK requires a network dispatcher for fetching feature definitions. Choose the appropriate one for your use case:OkHttp Dispatcher (Recommended)
Best for most server applications due to its smaller dependency footprint:Ktor CIO Dispatcher
Use this if you’re already using Ktor in your application:Configuration
Configure the GrowthBook SDK for your server environment:Evaluating Features and Running Experiments
Feature Flags
Evaluate feature flags to control application behavior:Feature Evaluation with Context
Update user attributes for different contexts:Running Experiments
Run A/B tests and experiments directly:Experiment Tracking
Track experiment exposures for analytics:Advanced Features
For more advanced usage including sticky bucketing, encrypted features, custom attributes, and mobile-specific considerations, see the Kotlin (Android) documentation which covers these topics in detail.Serialization Support
The optional serialization module provides helpers for working withGBValue and kotlinx.serialization:
When to Use SerializationYou only need the serialization module if you want to work with complex JSON feature values as typed Kotlin objects. For simple boolean, string, and number features, you can skip this dependency.
Caching and Server-Sent Events
Caching
The builder exposes acachingEnabled flag. On JVM, fetched features remain in the SDK instance after refresh, but there is no platform-provided persistent local cache layer:
setRefreshHandler() on the builder:
Real-time Updates with SSE
Start a persistent Server-Sent Events connection for live feature updates:Error Handling and Observability
Exception Handling
The SDK uses suspend functions and handles errors gracefully:Logging Integration
The SDK outputs debug information to stdout whenenableLogging is set to true. You can capture this in your application by redirecting stdout to your logging framework:
Testing
Mock Dispatchers
Use mock dispatchers for unit testing:Deterministic Testing
Use local JSON fixtures for predictable tests:Performance and Resource Usage
Connection Pooling
Configure connection pooling for high-throughput applications:Coroutine Dispatchers
Use appropriate dispatchers for different workloads:Avoid Blocking Calls
Never userunBlocking on request threads in server applications:
Framework Integration Examples
Ktor Server
Spring Boot
CLI Application
Versioning and Compatibility
Module Versions
GrowthBook Kotlin JVM modules follow independent versioning:Compatibility Matrix
Dependency Management
Pin JVM-specific versions explicitly in monorepos:Migration from Android Documentation
If you started with the Android documentation but need server-side usage:Key Differences
Migration Steps
- Update Dependencies: Replace Android artifacts with JVM variants
- Remove Android Engines: Use OkHttp or Ktor CIO only
- Update Network Dispatcher: Ensure JVM-compatible engines
- Review Threading: Remove
runBlockingfrom request handlers - Update Caching: Configure appropriate TTL for server usage
Troubleshooting
Common Issues
Problem:ClassNotFoundException for Android classes
Debug Logging
Enable debug logging to troubleshoot issues. The SDK prints to stdout whenenableLogging = true:
Supported Features
Further Reading
- Kotlin (Android) Documentation - For mobile app development
- Java SDK Documentation - Alternative JVM SDK
- GrowthBook API Reference - REST API documentation
- Feature Flag Best Practices - Feature management guide
Need help? Join our Slack community or check out our GitHub repository for examples and support.

