Skip to main content
SDKsAndroid

Troubleshooting

Symptom-driven debugging for the MotiSig Android SDK.

Symptoms grouped by area. Set logLevel = LogLevel.DEBUG in MotiSig.initialize and watch logcat — the SDK tags every line with the MotiSig tag and logs every queued mutation and HTTP failure.

adb logcat -s MotiSig:D

Initialization

SymptomLikely causeFix
MotiSig has not been initialized IllegalStateException from getInstance()initialize was never called, or sdkKey/projectId resolved to empty after the env-var fallback.Call MotiSig.initialize(this, ...) in Application.onCreate(). Confirm MOTISIG_SDK_KEY / MOTISIG_PROJECT_ID are set if you rely on them.
tryGetInstance() returns null after initializesdkKey / projectId were empty.The SDK refuses to bind without both; check the Logger.error line in logcat.
HTTP requests go to the wrong hostbaseURL was not passed and MOTISIG_BASE_URL is unset.Pass baseURL = URL("...") or set MOTISIG_BASE_URL. Default fallback is https://api.motisig.ai/client.
401 / 403 on every requestWrong sdkKey for the target environment.Confirm the key matches the project. Each request sends X-API-Key and X-Project-ID.

User and mutations

SymptomLikely causeFix
409 Conflict on setUserThe server already has this user id.Expected. The SDK treats 409 as success and persists the id locally.
triggerEvent callback never firesCallback runs on the main thread via Handler(Looper.getMainLooper()). If your app is paused or the main looper is blocked, it can appear stalled.Ensure the main thread is responsive. Use result.onSuccess / result.onFailure to inspect.
MotiSigError.UserNotSet from triggerEventsetUser has not been called yet (or logout ran).Call setUser before any user-scoped mutation. See User and profile.
Mutations sent in unexpected orderTwo threads enqueued mutations concurrently without synchronization.The SDK already serializes via FIFOMutationQueue; observable order is enqueue order. If you need stricter order, await your own coroutines/futures before enqueueing the next call.

Push registration (FCM)

SymptomLikely causeFix
Token never arrivesMotiSigFirebaseMessagingService not registered, or firebase-messaging dependency missing in the host app.Register the service in AndroidManifest.xml (or subclass it in your own FirebaseMessagingService). Add implementation("com.google.firebase:firebase-messaging:24.x.x") to the app module.
Notifications.getExpoPushTokenAsync errorsWrong SDK — that's the Expo SDK.This Android SDK uses FCM directly.
Push subscription not removed on logoutlogout() was called before any FCM token arrived.Without a token, there's nothing to remove server-side; the local clear still happens.
permission field in subscription is wrongThe user changed notification permission while the app was killed.The SDK patches permission on the next foreground resume. If you want immediate sync, call MotiSig.getInstance().setNotificationEnabled(true) (or false) which also patches permission.

Notification delivery

SymptomLikely causeFix
MotiSigNotificationListener never firesListener was garbage-collected (the SDK holds it weakly).Keep a strong reference (e.g. private val router = NotificationRouter() on a long-lived class).
onMessageReceived not called for background pushesThe push was sent as an FCM notification message, which auto-renders without invoking your service.Switch to a data-only message if you need onMessageReceived, or rely on handleNotificationIntent for taps.
Click tracking never fires on tapEither messageId is missing from the payload, no user is set, or handleNotificationIntent was not called from onCreate / onNewIntent.Confirm payload contains messageId; ensure setUser ran before the tap; forward the intent. Logs at DEBUG show "skipping click tracking".
Listener receives duplicate eventsBoth the live onMessageReceived path and fetchDeliveredNotifications() returned the same notification.Deduplicate with requestIdentifier and/or messageId. See Push notifications.
fetchDeliveredNotifications returns emptyAPI below 23, or there are no posted notifications, or your app process lost notification post permissions.Check Build.VERSION.SDK_INT; the callback always runs on the main thread.

Rich notification images

See Rich notification images for the dedicated checklist. Most common failures:

  • Sending a data-only message and not building a BigPictureStyle notification yourself.
  • Image URL not HTTPS, or returns 403/404.
  • Forgetting that FCM coerces data values to strings, so _motisig arrives as a JSON string blob (the example helper handles this).

Tests and CI

SymptomLikely causeFix
Integration tests skipMOTISIG_SDK_KEY / MOTISIG_PROJECT_ID / MOTISIG_BASE_URL not set.Set them in your test environment. See IntegrationTestCredentials.kt.
Unit tests run networkMotiSigTestBootstrap.skipPushPermissionAndRegistration not set.Toggle the test bootstrap flag in @BeforeAll to suppress the FCM token fetch.