Android

Add Fload's attribution SDK to an Android app, in Kotlin or Java. It takes one Gradle line and one call in your Application class.


What you need

  • minSdk 24 or later.
  • Your app's write key.
  • RevenueCat in your app, if you want revenue per keyword or campaign. The SDK doesn't depend on it.

1. Add the dependency

The library is built by JitPack from the SDK's GitHub releases. Add the JitPack repository in settings.gradle.kts:

kotlin
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven("https://jitpack.io")
    }
}

Then add the dependency in your app module's build.gradle.kts:

kotlin
dependencies {
    implementation("com.github.fload-ai:fload-attribution-android:1.0.2")
}

Still on Groovy? The same two steps:

groovy
// settings.gradle
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

// app/build.gradle
dependencies {
    implementation "com.github.fload-ai:fload-attribution-android:1.0.2"
}

Its one runtime dependency is Google's Play Install Referrer library. It adds the INTERNET and ACCESS_NETWORK_STATE permissions to your manifest, and ships its own R8 rules.


2. Start it in your Application class (Kotlin)

Call Fload.configure once, in Application.onCreate. It returns at once and does its work on its own background thread.

kotlin
import android.app.Application
import com.fload.attribution.Fload
import com.revenuecat.purchases.Purchases
import com.revenuecat.purchases.PurchasesConfiguration

class PocketBudgetApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Purchases.configure(PurchasesConfiguration.Builder(this, "goog_…").build())

        Fload.configure(this, key = "fload_pk_…")
        Fload.setUserId(Purchases.sharedInstance.appUserID)
    }
}

No Application class yet? Create one and name it in AndroidManifest.xml:

xml
<application
    android:name=".PocketBudgetApp"
    ... >

3. Or in Java

java
import android.app.Application;
import com.fload.attribution.Fload;
import com.revenuecat.purchases.Purchases;
import com.revenuecat.purchases.PurchasesConfiguration;

public class PocketBudgetApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Purchases.configure(new PurchasesConfiguration.Builder(this, "goog_…").build());

        Fload.configure(this, "fload_pk_…");
        Fload.setUserId(Purchases.getSharedInstance().getAppUserID());
    }
}

setUserId links this install to your user, so Fload can match it to RevenueCat's revenue. When a user logs in, RevenueCat's id changes. Send the new one once login finishes:

kotlin
Purchases.sharedInstance.logInWith(
    "user_123",
    onError = { /* handle it */ },
    onSuccess = { _, _ -> Fload.setUserId(Purchases.sharedInstance.appUserID) },
)

Fload keeps every id an install has had, so purchases before and after login both count. Calling setUserId again with the same id sends nothing.


5. Check it works

Turn on debug logs while you test:

kotlin
import com.fload.attribution.FloadLogLevel
import com.fload.attribution.FloadOptions

Fload.configure(this, "fload_pk_…", FloadOptions(logLevel = FloadLogLevel.DEBUG))

Filter Logcat by the tag FloadAttribution. By default the SDK logs warnings and errors only. Remove the debug option before you ship.

The referrer comes from Google Play, so it's only there for installs from Play. An app you install from Android Studio, or sideload, sends its install as having no referrer. That's expected.


6. Ship it

Ship the update. Installs start to arrive as people open the new version. Fill in your Data safety form from Privacy.


What the referrer tells Fload

The Play Install Referrer is the query string of the Play Store link a user followed, such as utm_source and utm_campaign. Fload reads it on the server. Unlike Apple's token, it's reported by the device and not signed, so Fload labels Android attribution as device-reported.


Reference

CallWhat it does
Fload.configure(context, key, options)Starts the SDK. Call once, in Application.onCreate
Fload.setUserId(userId)Links your user id to this install. Safe to call on every launch
Fload.installReferenceThis install's random reference, for support questions. null before configure
FloadOptions(logLevel = …)NONE, ERROR, WARNING (the default), INFO or DEBUG

Source code and changelog: github.com/fload-ai/fload-attribution-android.