LogDrop Android SDK
The LogDrop Android SDK is distributed via Gradle and integrates into your app using a flexible configuration builder.
1. SDK Installation
The SDK is published in LogDrop's own Maven repository. Add the repository to your project, then add the SDK as a dependency of your app module.
1.1. Add the LogDrop Maven repository
Gradle can download the SDK only from a repository your project lists, so add LogDrop's
repository next to google() and mavenCentral().
In your project-level build.gradle (or settings.gradle for Gradle 8+),
make sure the LogDrop repository is included:
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://artifactory.logdrop.io/repository/android-logdrop-sdk/" }
}
}If you are using the new Gradle version catalogs / dependencyResolutionManagement,
add the maven { ... } block there instead.
1.2. Add the SDK dependency
This line adds the LogDrop SDK to the app module that builds your application.
build.gradle:dependencies {
implementation "io.logdrop:sdk:2.1.16"
}The snippet above already shows the latest SDK version.
Sync Gradle after updating the configuration.
2. Initialization
Initialization starts the SDK and connects it to your LogDrop project. Initialize once, as early as possible, so that crashes and requests made during startup are captured.
Replace YOUR_APP_ID with the Mobile SDK App ID from Project Settings → App ID
in the panel. Set a base URL only if you use a self-hosted LogDrop.
Initialize LogDrop in your Application class.
class LogDropDemoApp : Application() {
override fun onCreate() {
super.onCreate()
// Required for accurate crash reporting and foreground/background tracking
LogDrop.registerActivityLifecycleCallback(this)
val config = LogDropConfig.Builder()
.appId("YOUR_APP_ID")
.baseUrl("YOUR_BASE_URL") // Optional: for self-hosted LogDrop
.logcatEnabled(true)
.build()
LogDrop.init(this, config)
}
}Crash tracking, HTTP logging, and sensitive info filters are resolved and controlled dynamically from the LogDrop backend (Settings -> App Config) rather than locally in the config builder.
End-to-end tracing
From SDK 2.1.11, requests the SDK tracks also carry a W3C traceparent header, so you can follow them into a backend traced by LogDrop. See Tracing.
Optionally, you can refresh the current FCM token after initialization:
FirebaseMessaging.getInstance().token
.addOnCompleteListener { task ->
if (!task.isSuccessful) return@addOnCompleteListener
task.result?.let { LogDrop.onNewFcmPushToken(it) }
}3. LogDropConfig Overview
LogDropConfig is the configuration you pass to LogDrop.init(...). appId is required.
The other fields point the SDK to a self-hosted LogDrop, turn on Logcat collection, or
connect your push, deep link and in-app callbacks. Crash tracking, HTTP logging and
sensitive info filters are not set here: you control them from the panel under
Settings → App Config.
-
appId: StringYour LogDrop project Application ID. Required. -
baseUrl: String?Custom backend URL for on-prem / self-hosted LogDrop deployments. -
logcatEnabled: BooleanEnables automatic collection of Logcat logs. -
pushCallbacks: LogDropPushCallbacks?Receives notification received, opened, and silent-push callbacks. -
pushDeeplinkHandler: LogDropPushDeeplinkHandler?Lets the application take over routing for push actions and deep links. -
inAppLifecycleCallbacks: LogDropInAppLifecycleCallbacks?Observes in-app popup presentation and dismissal. -
internalBrowserLifecycleCallbacks: LogDropInternalBrowserLifecycleCallbacks?Observes LogDrop's internal browser lifecycle. -
automaticScreenTracking: BooleanTracks Activities and AndroidX Fragments as screens automatically. Defaulttrue. See Screen Tracking.Use the
LogDropConfig.Builderto create the config instance in a safe and fluent way.
4. Crash Tracking (mapping upload)
When ProGuard or R8 obfuscates a release build, it renames classes and methods, so crash stack traces from that build are unreadable. The mapping file of each build records the original names.
To get human-readable stack traces, ProGuard/R8 mapping files must be uploaded to LogDrop.
LogDrop provides a Gradle plugin that automates mapping uploads during release builds. Tracing also needs this plugin.
4.1. Add the Gradle plugin dependency
The plugin is published in its own LogDrop repository. Add the repository and the plugin to the build script so Gradle can find the plugin.
build.gradle:buildscript {
repositories {
google()
mavenCentral()
maven { url "https://artifactory.logdrop.io/repository/logdrop-gradle-plugin/" }
}
dependencies {
classpath "io.logdrop.gradle:plugin:1.1.3"
}
}The snippet above already shows the latest plugin version.
4.2. Apply the plugin in the app module
The plugin works only in modules that apply it. Apply it in your app module, next to the Android and Kotlin plugins.
In your app module build.gradle (Kotlin DSL or Groovy):
plugins {
id "com.android.application"
id "org.jetbrains.kotlin.android"
id "io.logdrop.gradle.plugin"
}4.3. Create logdrop-services.json
logdrop-services.json tells the plugin which LogDrop project each build belongs to. It
maps each application ID of your app to an App ID, so that, for example, a .dev
variant can send to a different project than your main app.
In the app module root, create a file named logdrop-services.json:
{
"base_url": "<YOUR_BASE_URL>",
"projects": {
"com.yourcompany.yourapp": {
"app_id": "<YOUR_APP_ID>"
},
"com.yourcompany.yourapp.dev": {
"app_id": "<YOUR_DEV_APP_ID>"
}
}
}-
Keys under
projectsare your application IDs / namespaces. -
The plugin automatically selects the correct project and Application ID based on the current variant.
4.4. ProGuard / R8 configuration
Mapping files restore class and method names. File names and line numbers also need these two rules in your build.
In your
proguard-rules.pro(or equivalent), keep line number and source file attributes:
-keepattributes LineNumberTable,SourceFile
-renamesourcefileattribute SourceFileThis ensures LogDrop can show file names and line numbers in crash reports.
5. Logging Methods
Logging methods record your own messages at four levels: error (e), warning (w),
info (i) and debug (d). Use them to record what happens in your app, so you can
follow it later in the LogDrop panel. In these examples, each log also carries a
LogFlow, described in LogFlow.
LogDrop.e("PaymentActivity", "Payment failed", logFlow) // Error
LogDrop.w("Network", "Slow network", logFlow) // Warning
LogDrop.i("Auth", "User logged in", logFlow) // Info
LogDrop.d("Parser", "Parsing response", logFlow) // DebugLogs are stored locally on the device first. To send them to the server, call:
LogDrop.sendLogs()- Schedules a background job that runs approximately 60 seconds later.
- If a job is already scheduled or running, additional calls do not create new jobs.
6. Deep Links
A deep link is a URL that opens a specific screen in your app. LogDrop pushes and in-app messages can carry one.
If your app already handles deep links itself, forward the received intent to LogDrop manually, so the SDK can track the link.
Call LogDrop.onNewIntent(...) from the activity that owns the deep link intent-filter.
6.1. Cold Start
A cold start is when the link launches your app while it is not running. The link
arrives in the intent that starts the activity, so check it in onCreate.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (intent?.action == Intent.ACTION_VIEW && intent?.data != null) {
LogDrop.onNewIntent(this, intent)
}
}6.2. App Already Open (singleTop / singleTask)
When the activity is already running and uses the singleTop or singleTask launch
mode, Android delivers the new link to onNewIntent instead of creating a new activity.
Forward it from there.
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
if (intent.action == Intent.ACTION_VIEW && intent.data != null) {
LogDrop.onNewIntent(this, intent)
}
}Only add this to the activity that actually receives the deep link intent.
7. LogFlow
LogFlow lets you group related logs under a specific business flow or transaction.
A flow has a name, an ID and optional custom attributes. Pass the same flow to every
log of one piece of work, such as one checkout or one payment, so the panel can show
those logs together.
val flow = LogFlow(
name = "SuccessTransaction",
id = transactionId,
customAttributes = mapOf(
"amount" to "149.90",
"currency" to "TRY"
)
)
LogDrop.i("TransactionActivity", "Transaction completed successfully.", flow)In the LogDrop panel you can filter and analyze logs by flowName and flowId.
8. Push Notification Integration
LogDrop supports alert, rich, in-app, deep-link, internal-browser, and silent
fetch-logs pushes. Forward messages recognized by LogDrop.isLogDropPush(...)
to the SDK from your messaging service.
With push integrated, you can send messages to your users from Push Notification in the panel or from a Customer Journey. Fetch Logs in the panel also uses a silent push to ask a device to upload its logs. The panel needs your FCM credentials, and HMS credentials if you support Huawei devices, under Settings → Push Backends.
8.1. Firebase Cloud Messaging (FCM)
FCM delivers push messages and token updates to your app through a
FirebaseMessagingService. In your service, pass LogDrop's messages and each new token
to the SDK, and keep handling your other messages as before.
FirebaseMessagingService:class LogDropDemoMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
if (LogDrop.isLogDropPush(remoteMessage.data)) {
LogDrop.onRemoteMessageReceived(
context = this,
data = remoteMessage.data,
notificationTitle = remoteMessage.notification?.title,
notificationBody = remoteMessage.notification?.body
)
}
}
override fun onNewToken(token: String) {
super.onNewToken(token)
LogDrop.onNewFcmPushToken(token)
}
}-
isLogDropPush(data)Identifies messages owned by LogDrop without intercepting the application's other FCM messages. -
onRemoteMessageReceived(...)Displays and tracks LogDrop pushes or handles silent fetch-logs commands. -
onNewFcmPushToken(token: String)Updates the FCM token used by LogDrop. -
Make sure the service is declared in your
AndroidManifest.xml.8.2. Show a Pending In-App Push
An in-app message is a modal or banner that a LogDrop push shows inside your app. LogDrop keeps in-app popups and internal-browser actions from pushes in a queue until your app asks to show them.
When an activity is ready to present UI, ask LogDrop to show any queued in-app popup or internal-browser action:
override fun onResume() {
super.onResume()
LogDrop.showPendingPushPopup(this)
}The method returns LogDropPopupShowResult, which can be used if the application
needs to react to whether an item was shown, unavailable, or not pending.
8.3. Huawei Mobile Services (HMS) – optional
Huawei devices without Google Mobile Services (GMS) receive pushes through HMS instead of FCM. Skip this section if your app does not support those devices.
If you support Huawei devices without GMS, implement HmsMessageService:
class LogDropDemoHmsMessagingService : HmsMessageService() {
override fun onNewToken(token: String) {
super.onNewToken(token)
LogDrop.onNewHmsPushToken(token)
}
override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
if (LogDrop.isLogDropPush(remoteMessage.dataOfMap)) {
LogDrop.onRemoteMessageReceived(
context = this,
data = remoteMessage.dataOfMap
)
}
}
}onRemoteMessageReceived(...)Handles LogDrop alert and silent pushes via HMS.onNewHmsPushToken(token: String)Updates the HMS push token used by LogDrop.
9. User Identification (UUID Customization)
By default, logs are tied to a device identifier. Set your own user ID when you want to find a user's data by that ID: you can then search for it as User UUID on the panel's Devices page.
To associate logs with your own user ID:
LogDrop.userUpdate(userId = "user-1234@example.com")You can use any stable, unique identifier, such as:
-
Email address
-
Internal customer ID
-
Other application-specific user ID
All subsequent logs will be associated with this user in the LogDrop panel.
10. Custom Events
Use custom events to track application-specific actions that are not covered by LogDrop's built-in events. Send a stable event name together with optional JSON-compatible properties.
10.1. Track a Custom Event
Call trackCustomEvent when the action happens in your app. Pass the event name and,
if you need them, properties that describe this occurrence.
LogDrop.trackCustomEvent(
eventName = "purchase_completed",
properties = mapOf(
"coupon_code" to "SUMMER10",
"amount" to 49.9,
"item_count" to 2,
"is_first_order" to true
)
)Properties are optional. To track an event without properties:
LogDrop.trackCustomEvent(eventName = "onboarding_completed")Provide only the readable event name and properties. Event and property codes shown in the panel are managed by LogDrop.
10.2. Supported Property Values
Custom properties may contain strings, numbers, booleans, Date values, null,
nested maps, collections, and arrays. Map keys must be strings.
LogDrop.trackCustomEvent(
eventName = "product_viewed",
properties = mapOf(
"sku" to "LD-100",
"viewed_at" to java.util.Date(),
"product" to mapOf(
"name" to "LogDrop Hoodie",
"price" to 79.95
),
"categories" to listOf("merch", "hoodies"),
"variants" to listOf(
mapOf("color" to "black", "size" to "M"),
mapOf("color" to "green", "size" to "L")
),
"campaign" to null
)
)Date values are represented as UTC ISO-8601 strings in LogDrop. Nested objects and
arrays remain structured values.
10.3. Naming and Property Types
LogDrop keeps one schema per event name, built from the properties you send. Follow these rules so the same action always lands in the same event, with the same property types:
- Use stable and consistent names. For example, do not alternate between
purchase_completedandpurchaseCompletedfor the same event. - Do not put IDs, timestamps, or other dynamic values in the event name. Add them as properties instead.
- Do not use the name of a LogDrop default event for a custom event.
- Keep each property's type stable. For example, always send
amountas a number rather than sometimes sending a number and sometimes a string. - Reusing the same event name updates the same custom event schema. Changing the name creates a different custom event.
If a property is later sent with a different type, LogDrop keeps the event but marks the property as a type conflict in the panel. Type conflict tracking helps find integration mistakes; it should not be used as a replacement for a stable event contract.
10.4. Limits and Validation
The SDK checks each event on the device before sending it. An event that breaks any of these rules is not sent.
- Event names can contain up to 128 characters.
- Property names can contain up to 128 characters.
- One event can contain up to 100 top-level properties.
- The complete properties JSON can contain up to 16 KB in UTF-8, including property names, primitive values, nested objects, and arrays.
- Event names and property names cannot be empty.
- Property values must be JSON-compatible.
If validation fails, the SDK rejects the complete event and writes the reason to the SDK log. Names, properties, and payloads are never silently truncated.
10.5. Panel Behavior
No custom event definition is required before tracking. After the first valid event reaches LogDrop, the Events page shows the event, its generated code, observed properties, property types, and any type conflicts. You can then use the event in event details and Event Analytics funnels.
11. Custom User Attributes
Custom user attributes let you attach stable profile information to the current
LogDrop device and use it for segment-based push targeting in the panel. Call the
API after LogDrop.init(...) has completed.
Customer Journeys also use these attributes as the recipient phone and consent fields of SMS and WhatsApp steps.
11.1. Set or Update Attributes
Pass the attribute keys with string values. Call it whenever a profile value changes.
LogDrop.setCustomAttributes(
mapOf(
"plan_type" to "premium",
"country" to "TR",
"preferred_language" to "tr"
)
)New attributes are merged with the values already stored by the SDK. Sending an existing key replaces its value; other keys remain unchanged. Valid changes are persisted locally and synchronized with LogDrop automatically.
11.2. Remove an Attribute
Remove a key when its value no longer applies to the device.
LogDrop.removeCustomAttribute("plan_type")Removing a key also synchronizes the deletion with LogDrop, so the old value is no longer available for future segment targeting.
11.3. Limits and Validation
The SDK checks each update on the device before it stores or sends it.
- A device can have up to 30 custom attributes in total.
- Keys must contain only letters, numbers, underscores (
_), or hyphens (-). - Keys can contain up to 64 characters.
- Values must be non-blank strings containing up to 256 characters.
- If one entry in a call is invalid, the SDK rejects the complete update.
- If the merged result would exceed 30 keys, the SDK keeps the previous attribute set unchanged.
Custom user attributes are different from LogFlow.customAttributes. User attributes
describe a device for audience targeting, while flow attributes add context only to the
logs recorded with that LogFlow.
11.4. Use Attributes in the Panel
After the device synchronizes, open Push Notification → Send Push, select Segment under Recipients, and build a filter with the attribute key. See Segment Targeting with Custom Attributes.
12. Screen Tracking
From SDK 2.1.16, the SDK knows which screen the user is looking at. Each screen change is
recorded as a screen_view event with the screen name (screen_name), the previous screen
(previous_screen_name) and how the screen was detected (screen_kind). App Health uses the
screen names to break performance metrics down by screen, and HTTP records show the screen
a request started on.
App Health metrics
The SDK also sends app start time, slow and frozen frames, freezes and ANRs, memory, CPU, battery, network and HTTP timing metrics with each session for the panel's App Health page. They need no code.
12.1. Automatic Tracking
Activities and AndroidX Fragments are tracked automatically, under their class name. A
Fragment shown with its Activity is tracked instead of the Activity. Give a screen a
stable name, or leave it out, with the @LogDropScreen annotation:
@LogDropScreen(name = "Checkout")
class CheckoutFragment : Fragment()
@LogDropScreen(ignore = true)
class DebugMenuActivity : AppCompatActivity()R8 renames classes in release builds. Fragments whose class name is obfuscated are not tracked
unless they have @LogDropScreen(name = ...), so name the Fragments you want to see in release builds.
12.2. Jetpack Navigation
Call trackNavigation once for each NavController, for example right after you create
it. Destinations are then tracked by route template (for example product/{id}) or label,
and the hosting Activity and its Fragments are no longer tracked separately.
import io.logdrop.sdk.trackNavigation
LogDrop.trackNavigation(navController)From Java, call LogDropNavigation.trackNavigation(LogDrop.INSTANCE, navController).
12.3. Manual Screens
For UIs automatic tracking cannot see, such as Jetpack Compose without Navigation, set the
screen yourself. A screen_view is recorded when the name differs from the current screen.
LogDrop.trackScreen("ProductDetail")-
Keep screen names stable and free of user data:
ProductDetail, not the product's name. -
Names longer than 100 characters are cut; blank names are ignored.
To name screens only from your code, turn automatic tracking off:
val config = LogDropConfig.Builder()
.appId("YOUR_APP_ID")
.automaticScreenTracking(false)
.build()13. Troubleshooting
If data does not reach LogDrop, crash reports stay unreadable, pushes do not arrive, or events and attributes are missing, check these common causes first.
- Verify that the
logdrop-services.jsonfile exists in the app module and that itsprojectskeys match your application IDs. - Make sure the LogDrop Gradle plugin is applied and the repository URL is correct.
- Confirm that mapping files are being uploaded for release builds (check the Gradle build output).
- Ensure that
LogDrop.registerActivityLifecycleCallback(this)is called beforeLogDrop.init(...). - Check that your FCM/HMS messaging services are correctly registered in
AndroidManifest.xml. - Confirm that custom event names do not match LogDrop default event names.
- Check SDK logs when a custom event is missing; invalid names, properties, or oversized payloads are rejected locally.
- Check SDK logs when custom user attributes are missing; invalid updates and updates exceeding 30 keys are rejected locally.
- In development, enable verbose logging with:
val config = LogDropConfig.Builder()
.appId("YOUR_APP_ID")
.logcatEnabled(true)
// ...
.build().png)