Skip to main content

Overview

The Kount Android SDK provides several configuration options to customize its behavior for your application. This guide covers all available configuration methods, their parameters, and best practices.

Required Configuration

Before collecting device data, you must configure the SDK with at least your Merchant ID:
import com.kount.api.KountSDK;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // Minimum required configuration
        KountSDK.INSTANCE.setMerchantId("999999");
    }
}
The SDK will not function properly without a valid Merchant ID. Contact Kount support to obtain your production Merchant ID.

Configuration Methods

setMerchantId()

Sets your unique Kount Merchant ID. Parameters:
  • merchantId (String): Your 6-digit Kount Merchant ID
Example:
KountSDK.INSTANCE.setMerchantId("999999");
“999999” is the test Merchant ID. Replace it with your actual Merchant ID for production use.

setEnvironment()

Configures the SDK to use either the test or production environment. Parameters:
  • environment (int): The target environment
    • KountSDK.ENVIRONMENT_TEST - Test environment (default)
    • KountSDK.ENVIRONMENT_PRODUCTION - Production environment
Example:
// Test environment
KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST);

// Production environment
KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_PRODUCTION);
Environment Details:
EnvironmentValueDescriptionUse Case
ENVIRONMENT_TESTTestSends data to Kount’s test serversDevelopment and testing
ENVIRONMENT_PRODUCTIONProductionSends data to Kount’s production serversLive production apps
Always use ENVIRONMENT_TEST during development and testing. Switch to ENVIRONMENT_PRODUCTION only for production releases.

setCollectAnalytics()

Enables or disables advanced analytics collection. Parameters:
  • enabled (boolean):
    • true - Enable analytics collection (default)
    • false - Disable analytics collection
Example:
// Enable analytics (default)
KountSDK.INSTANCE.setCollectAnalytics(true);

// Disable analytics
KountSDK.INSTANCE.setCollectAnalytics(false);
What Analytics Includes:
  • Device behavioral patterns
  • App interaction metrics
  • Enhanced fraud signals
  • Advanced device fingerprinting
Keeping analytics enabled (default) provides the most accurate fraud detection. Only disable if you have specific privacy or performance requirements.

Complete Configuration Example

Java Example

package com.kount.checkoutexample;

import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import com.kount.api.KountSDK;

public class MainActivity extends AppCompatActivity {
    
    // Configuration constants
    private static final String MERCHANT_ID = "999999";
    private static final int ENVIRONMENT = KountSDK.ENVIRONMENT_TEST;
    private static final boolean ANALYTICS_ENABLED = true;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        // Configure SDK
        configureKountSDK();
        
        // Verify configuration
        logConfiguration();
    }
    
    private void configureKountSDK() {
        // Set merchant ID (required)
        KountSDK.INSTANCE.setMerchantId(MERCHANT_ID);
        
        // Set environment
        KountSDK.INSTANCE.setEnvironment(ENVIRONMENT);
        
        // Enable/disable analytics
        KountSDK.INSTANCE.setCollectAnalytics(ANALYTICS_ENABLED);
        
        Log.d("KountSDK", "SDK configured successfully");
    }
    
    private void logConfiguration() {
        String envName = ENVIRONMENT == KountSDK.ENVIRONMENT_TEST ? "Test" : "Production";
        Log.d("KountSDK", "Merchant ID: " + MERCHANT_ID);
        Log.d("KountSDK", "Environment: " + envName);
        Log.d("KountSDK", "Analytics: " + (ANALYTICS_ENABLED ? "Enabled" : "Disabled"));
        Log.d("KountSDK", "Status: " + KountSDK.INSTANCE.getCollectionStatus());
    }
}

Kotlin Example

package com.kount.checkoutexample.kotlin

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.kount.api.KountSDK

class MainActivity : AppCompatActivity() {
    
    companion object {
        const val MERCHANT_ID = "999999"
        const val ENVIRONMENT = KountSDK.ENVIRONMENT_TEST
        const val ANALYTICS_ENABLED = true
    }
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        
        // Configure SDK
        configureKountSDK()
        
        // Verify configuration
        logConfiguration()
    }
    
    private fun configureKountSDK() {
        // Set merchant ID (required)
        KountSDK.setMerchantId(MERCHANT_ID)
        
        // Set environment
        KountSDK.setEnvironment(ENVIRONMENT)
        
        // Enable/disable analytics
        KountSDK.setCollectAnalytics(ANALYTICS_ENABLED)
        
        Log.d("KountSDK", "SDK configured successfully")
    }
    
    private fun logConfiguration() {
        val envName = when (ENVIRONMENT) {
            KountSDK.ENVIRONMENT_TEST -> "Test"
            KountSDK.ENVIRONMENT_PRODUCTION -> "Production"
            else -> "Unknown"
        }
        
        Log.d("KountSDK", "Merchant ID: $MERCHANT_ID")
        Log.d("KountSDK", "Environment: $envName")
        Log.d("KountSDK", "Analytics: ${if (ANALYTICS_ENABLED) "Enabled" else "Disabled"}")
        Log.d("KountSDK", "Status: ${KountSDK.getCollectionStatus()}")
    }
}

Configuration Order

The order of configuration calls does not matter, but all configuration must be completed before calling collectForSession():
// Correct - all configuration before collection
KountSDK.INSTANCE.setMerchantId("999999");
KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST);
KountSDK.INSTANCE.setCollectAnalytics(true);
KountSDK.INSTANCE.collectForSession(this, successCallback, failureCallback);

// Also correct - different order
KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST);
KountSDK.INSTANCE.setCollectAnalytics(true);
KountSDK.INSTANCE.setMerchantId("999999");
KountSDK.INSTANCE.collectForSession(this, successCallback, failureCallback);

Build-Specific Configuration

Use BuildConfig to automatically switch configurations based on build type:
public class MainActivity extends AppCompatActivity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // Automatically configure based on build type
        KountSDK.INSTANCE.setMerchantId(getMerchantId());
        KountSDK.INSTANCE.setEnvironment(getEnvironment());
        KountSDK.INSTANCE.setCollectAnalytics(BuildConfig.DEBUG);
    }
    
    private String getMerchantId() {
        return BuildConfig.DEBUG ? "999999" : "123456";
    }
    
    private int getEnvironment() {
        return BuildConfig.DEBUG 
            ? KountSDK.ENVIRONMENT_TEST 
            : KountSDK.ENVIRONMENT_PRODUCTION;
    }
}

Using Gradle Build Variants

Define configurations in build.gradle:
android {
    buildTypes {
        debug {
            buildConfigField "String", "KOUNT_MERCHANT_ID", '"999999"'
            buildConfigField "int", "KOUNT_ENVIRONMENT", "0" // TEST
        }
        release {
            buildConfigField "String", "KOUNT_MERCHANT_ID", '"123456"'
            buildConfigField "int", "KOUNT_ENVIRONMENT", "1" // PRODUCTION
        }
    }
}
Then use in code:
KountSDK.INSTANCE.setMerchantId(BuildConfig.KOUNT_MERCHANT_ID);
KountSDK.INSTANCE.setEnvironment(BuildConfig.KOUNT_ENVIRONMENT);

Configuration Validation

Verify your configuration is correct:
private void validateConfiguration() {
    // Check collection status
    String status = KountSDK.INSTANCE.getCollectionStatus();
    Log.d("TAG", "Collection Status: " + status);
    
    // Verify configuration before proceeding
    if (status.equals("NOT_CONFIGURED")) {
        Log.e("TAG", "SDK not properly configured!");
        // Handle error
    }
}

Configuration Checklist

Before releasing to production, verify:
1

Merchant ID Set

Ensure you’ve called setMerchantId() with your production Merchant ID
2

Production Environment

Verify setEnvironment(KountSDK.ENVIRONMENT_PRODUCTION) for release builds
3

Analytics Configured

Decide if analytics should be enabled based on your requirements
4

Configuration Timing

Confirm all configuration is done before calling collectForSession()
5

Test Both Environments

Test your app in both test and production configurations

Best Practices

Early Configuration

Configure the SDK as early as possible, ideally in Application.onCreate() or the first Activity’s onCreate().

Use Constants

Store configuration values as constants or in BuildConfig for easy maintenance and build variant support.

Environment Separation

Always use separate Merchant IDs for test and production environments. Never use test credentials in production.

Validate Configuration

Check the collection status after configuration to catch issues early.

Common Configuration Patterns

Application-Level Configuration

Configure once in your Application class:
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        
        // Configure SDK once for the entire app
        KountSDK.INSTANCE.setMerchantId("999999");
        KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST);
        KountSDK.INSTANCE.setCollectAnalytics(true);
    }
}
Don’t forget to register in AndroidManifest.xml:
<application
    android:name=".MyApplication"
    ...>
</application>

Configuration Helper Class

Create a dedicated configuration class:
public class KountConfig {
    private static final String MERCHANT_ID = "999999";
    
    public static void initialize(Context context) {
        KountSDK.INSTANCE.setMerchantId(MERCHANT_ID);
        KountSDK.INSTANCE.setEnvironment(
            BuildConfig.DEBUG 
                ? KountSDK.ENVIRONMENT_TEST 
                : KountSDK.ENVIRONMENT_PRODUCTION
        );
        KountSDK.INSTANCE.setCollectAnalytics(true);
    }
}

// Usage
KountConfig.initialize(this);

Troubleshooting

  • Verify setMerchantId() was called with a valid Merchant ID
  • Check that configuration was completed before collectForSession()
  • Ensure you have internet permission in AndroidManifest.xml
  • Review logs for any error messages
  • Double-check the setEnvironment() call
  • Verify build variant configuration in build.gradle
  • Use logging to confirm which environment is set at runtime
  • Test with a debugger to inspect the environment value
  • Confirm setCollectAnalytics(true) was called
  • Check that analytics is not disabled by build configuration
  • Verify no ProGuard/R8 rules are interfering with SDK classes

Next Steps

Java Integration

Complete Java integration guide

Kotlin Integration

Complete Kotlin integration guide

Permission Handling

Handle location permissions correctly

API Reference

Complete API documentation

Build docs developers (and LLMs) love