2. Install the Airflux SDK
1. SDK Installation
Declare the SDK Repository
To install the Airflux Android SDK, you need to declare the SDK repository to only one file settings.gradle or build.gradle.
Case A: If your project-level settings.gradle file contains dependencyResolutionManagement block, add the SDK repository to the repositories block in the file.
dependencyResolutionManagement {
repositories {
maven { url = "https://sdk-download.airflux.ai/maven" }
}
}dependencyResolutionManagement {
repositories {
maven { url = uri("https://sdk-download.airflux.ai/maven") }
}
}Case B: If your project-level build.gradle file contains allprojects block, add the SDK repository to the repositories block in the file.
allprojects {
repositories {
maven { url = "https://sdk-download.airflux.ai/maven" }
}
}allprojects {
repositories {
maven { url = uri("https://sdk-download.airflux.ai/maven") }
}
}Add the SDK Package
Add the SDK as a dependency in your app-level app/build.gradle file. Replace $HERE_LATEST_VERSION with the latest SDK version, available on the Airflux SDK Versions page.
dependencies {
// Replace $HERE_LATEST_VERSION with the latest version from the SDK Versions page.
implementation "ai.airflux:sdk-android:$HERE_LATEST_VERSION"
}dependencies {
// Replace $HERE_LATEST_VERSION with the latest version from the SDK Versions page.
implementation("ai.airflux:sdk-android:$HERE_LATEST_VERSION")
}2. SDK Initialization
Initialize the SDK
Initialize the SDK within the onCreate() method of your MainApplication class. This ensures the SDK is ready as soon as the app launches.
App Name
AirfluxOptionBuilder()
string
Input the App Name from the Airbridge dashboard.
Required
App Token
AirfluxOptionBuilder()
string
Input the App Token from the Airbridge dashboard.
Required
SDK Enabled
setSDKEnabled()
boolean
Set whether to enable the SDK upon initialization.
true: The SDK is initialized in active mode.
false: The SDK is initialized in inactive mode and is enabled upon calling the
Airflux.EnableSDK()function.
Optional
Auto Start Tracking Enabled
setAutoStartTrackingEnabled()
boolean
Set whether to collect events automatically upon SDK initialization.
true: Event collection starts automatically upon initialization.
false: Event collection starts upon calling the
Airflux.StartTracking()function.
Optional
Log Level
setLogLevel()
AirfluxLogLevel
Set the log level for the Airflux SDK. Choose from debug, info, warning, error, fault .
Optional
Session Timeout
setSessionTimeout()
double
The default value is 300 seconds. Modify if needed.
Optional
Allow Every Country Enabled
setAllowEveryCountryEnabled()
boolean
When set to true, all countries are allowed to follow Airflux's optimization policies. To use a specific list of countries, set it to false and provide a list using setCountryAllowlist().
Optional
Country Allowlist
setCountryAllowlist()
List<String>
Set the countries where calling the Airflux's inference API should be allowed. Use country codes following the ISO 3166-1 alpha-2 format (e.g., US, KR). You can set multiple countries using the Country Allowlist. Airflux identifies a country based on the value tied to the device.
Optional
import ai.airflux.Airflux
import ai.airflux.AirfluxOptionBuilder
import ai.airflux.AirfluxLogLevel
import android.app.Application
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
// Creates the option for initializing the Airflux SDK.
// Replace "YOUR_APP_NAME" and "YOUR_APP_TOKEN" with your actual credentials.
val option = AirfluxOptionBuilder("YOUR_APP_NAME", "YOUR_APP_TOKEN")
// Automatically enables the SDK on startup.
.setSDKEnabled(true)
// Automatically starts tracking events.
.setAutoStartTrackingEnabled(true)
// Sets the log level to debug for detailed logs.
.setLogLevel(AirfluxLogLevel.DEBUG)
// Sets the session timeout to 300 seconds (5 minutes).
.setSessionTimeout(300)
// Allows Airflux features in all countries.
.setAllowEveryCountryEnabled(true)
// Uncomment the line below to allow only specific countries.
// .setCountryAllowlist(listOf("US", "KR", "JP"))
.build()
Airflux.initializeSDK(this, option)
}
}import ai.airflux.Airflux;
import ai.airflux.AirfluxOption;
import ai.airflux.AirfluxOptionBuilder;
import ai.airflux.AirfluxLogLevel;
import android.app.Application;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
final AirfluxOption option = new AirfluxOptionBuilder("YOUR_APP_NAME", "YOUR_APP_TOKEN")
// Automatically enables the SDK on startup.
.setSDKEnabled(true)
// Automatically starts tracking events.
.setAutoStartTrackingEnabled(true)
// Sets the log level to debug for detailed logs.
.setLogLevel(AirfluxLogLevel.DEBUG)
// Sets the session timeout to 300 seconds (5 minutes).
.setSessionTimeout(300)
.setAllowEveryCountryEnabled(true)
// Uncomment the line below to allow only specific countries.
// .setCountryAllowlist(Arrays.asList("US", "KR", "JP"))
.build();
// Initializes the SDK using the configured option.
Airflux.initializeSDK(this, option);
}
}3. Verification
Android Logcat check
To view detailed log information for your app, use the Android Logcat tool.
You can set the log output level using the setLogLevel function.
Setting it to AirfluxLogLevel.DEBUG allows you to see all Airflux logs.
4. Frequently Asked Questions
5. Troubleshooting
Last updated

