Skip to content

Android AAR SDK for Referer

lib.apkreferer:reader:1.0.0

The SDK is delivered as an AAR. It supports Android API 24 and later.

Put the AAR in your app’s libs/ directory:

dependencies {
implementation(files("libs/apk-referer-reader-1.0.0.aar"))
}

If you use an internal Maven repository, publish the AAR there and use the coordinates above.

import lib.apkreferer.reader.RefererReader
import lib.apkreferer.reader.RefererResult
val result = RefererReader.read(context)
when (result) {
is RefererResult.Found -> {
val referer = result.referer
// Use the channel parameter in your business logic.
}
RefererResult.NotFound -> {
// This APK has no channel parameter.
}
is RefererResult.Error -> {
// result.code / result.message
}
}

read() is synchronous and creates no thread. Call it from a background thread. It reads only the current app’s installed APK and needs no storage permission.

  • Found: the channel parameter was found and is returned as a string.
  • NotFound: the APK is valid but has no channel parameter.
  • Error: the APK is missing, unreadable, unsupported, or the parameter is invalid. Use code for program logic and message for diagnostics.

The SDK never logs the full channel value. Handle Error in your app; do not assume a value is always present.