Skip to main content
Configures the shared Encore instance for use throughout your app. This must be called once, typically in your Application.onCreate(), before using any other SDK methods.
Call configure() before using any other SDK methods. Failure to do so will result in EncoreError.Integration.NotConfigured errors.

Signature

fun configure(
    context: Context,
    apiKey: String,
    logLevel: LogLevel = LogLevel.NONE
)

Parameters

NameTypeDefaultDescription
contextContextYour application context
apiKeyStringYour Live Key or Test Key from the Encore Dashboard settings
logLevelLogLevelLogLevel.NONELogging verbosity level

Log levels

enum class LogLevel(val level: Int) {
    NONE(0),    // No logging (recommended for production)
    ERROR(1),   // Only errors
    WARN(2),    // Warnings and errors
    INFO(3),    // Milestones, warnings, and errors
    DEBUG(4),   // Everything (verbose, development only)
}
Higher levels include all lower levels. For example, INFO will also show warnings and errors.

API keys

Encore supports two types of API keys:
Key TypeFormatDescription
Live Keypk_live_...Production key with standard geo-filtering based on offers’ configured regions
Test Keypk_test_...Testing key that bypasses geo-filtering, allowing you to test the complete entitlement lifecycle from any location
Use the test key (pk_test_...) during development to test offers from any location without geo-filtering restrictions. This makes it easy to test the entire entitlement lifecycle end-to-end for a single user.
Always use your live key (pk_live_...) in production builds. The test key is for development and testing only.

Usage

Basic Configuration

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Encore.shared.configure(this, apiKey = "pk_your_api_key")
    }
}

With Debug Logging (Development)

Encore.shared.configure(
    context = this,
    apiKey = "pk_your_api_key",
    logLevel = if (BuildConfig.DEBUG) LogLevel.DEBUG else LogLevel.NONE
)

Using Test Key for Development

Use the test key to test offers from any location without geo-filtering:
Encore.shared.configure(
    context = this,
    apiKey = if (BuildConfig.DEBUG) "pk_test_your_key" else "pk_live_your_key",
    logLevel = if (BuildConfig.DEBUG) LogLevel.DEBUG else LogLevel.NONE
)
The test key (pk_test_...) is perfect for comprehensive end-to-end testing of the entitlement lifecycle, allowing you to test location-restricted offers from anywhere during development.
Use LogLevel.DEBUG during development to see detailed SDK logs, then use LogLevel.NONE for production builds.