Skip to main content

Android Troubleshooting

Problems specific to the Android SDK. Start with the platform independent checks in Troubleshooting, especially when events are missing in the panel.


Diagnostic steps​

  1. Check the SDK version in your build.gradle.kts. This page describes the current version. On 1.x, see Older SDK versions and the Migration Guide.
  2. Turn on UserCom.debugLogging and filter Logcat by the tag UserCom. The log says when the SDK sends a request, and why it does not show a push notification or an in-app message.
  3. Print UserCom.default?.userKey after the first ping. If it is null, the SDK has no contact yet and does not send events.
  4. Read the callbacks of ping, sendEvent and trackScreen, or set UserCom.errorHandler, and log the errors. See Errors.
  5. Find the contact with this key in the panel and compare it with the contact you were looking at.
  6. Check that UserCom.initialize runs in Application.onCreate.

Setup and build​

Every call fails with InvalidConfiguration

Every callback reports InvalidConfiguration at once, and no request is sent.

Cause: the base URL passed to initialize is not a full URL, usually because https:// is missing, or the API key is empty.

Fix: pass the full workspace address, for example https://your-domain.user.com, and a non empty Mobile SDK key.

The build fails: a dependency requires compileSdk 34, or Kotlin metadata is incompatible

Causes:

  • compileSdk is lower than 34,
  • your app uses Kotlin earlier than 1.8.

Fix:

  1. Raise compileSdk to 34 or later.
  2. Use Kotlin 1.8 or later. See Installation.

Contacts​

After switching baseUrl, events go to an unknown contact or are rejected

For example after switching from staging to production.

Cause: the contact key is kept when baseUrl changes.

Fix: clear the app data or reinstall the app before testing with another workspace, or call logout once after switching.

A user who restored a backup on a new phone appears as a new anonymous contact

Cause: the contact key is not part of the app backup, so two phones never share a contact by accident.

Fix: none needed. Call updateContact with the user ID at login, and the activity joins the user's contact.


Events​

Events fail with NotIdentified

The callback of sendEvent, trackScreen or sendProductEvent reports NotIdentified at once. The SDK sends no request, so a network proxy shows no event traffic at all.

Causes:

  • the event was sent before the first successful ping of this installation,
  • neither ping() nor setFcmToken is called, or the ping fails (wrong key, wrong domain, no network on first launch). initialize does not ping by itself.

Fix:

  1. Call ping() after initialize on every launch.
  2. Check its callback. Rejected with status 401 means the Mobile SDK key is wrong, regenerated, or is the REST API key. See Nothing reaches the panel.
  3. Send events after the ping succeeds, for example from its callback on the first launch.

Push notifications​

The contact cannot be selected in a push or in-app campaign

Cause: the panel offers only contacts with a device that has a push token. Common reasons:

  • no FCM token passed to the SDK. The SDK does not fetch it from Firebase, so after updating from 1.x your app must pass it,
  • the token moved to another contact on the same device: a push token belongs to the device, and a ping with it moves the device to the contact that sent the ping, for example after another user logged in on that device or after logout.

Fix:

  1. Call setFcmToken at launch and in onNewToken. See Push Token.
  2. Open the app, so the next ping registers the current token on the current contact.

Push notifications and in-app messages reach one device per contact: the device that last sent a ping with a token for that contact.

The campaign is sent, but the push notification never appears

Causes:

  • the panel uses a service account key from a different Firebase project than your google-services.json,
  • notifications are turned off for the app, or the user turned off the "Marketing Notifications" channel,
  • on Android 13 or later, the app has no notification permission,
  • the network drops idle connections, for example a company VPN, which delays Firebase delivery for all apps on the device.

Fix:

  1. Compare the Firebase project in google-services.json with the one in the panel.
  2. Check the notification settings of the app and of the channel.
  3. Ask for the notification permission in your app.
  4. Test on mobile data or another Wi-Fi.

With UserCom.debugLogging on, a push notification the SDK did not show in the foreground leaves a line in the log with the reason.

The notification icon or colour changes depending on whether the app was open

Cause: in the background Android shows the notification from the Firebase meta-data keys. The SDK reads the same keys and ignores com.user.sdk.default_notification_icon and _color, which you may still have after updating from 1.x.

Fix: set the icon and colour with com.google.firebase.messaging.default_notification_icon and _color. See Icon and colour.

Users tap push notifications, but the panel shows no clicks

Causes:

  • the activity the tap opens does not call handleNotificationClick, for example a splash screen that starts another activity first,
  • onNewIntent is missing, so taps while the app is open are not passed on,
  • handleNotificationClick runs before UserCom.initialize.

Fix:

  1. Call handleNotificationClick(intent) in onCreate and onNewIntent of your launcher activity.
  2. Initialize the SDK in Application.onCreate.

In-app messages​

Push notifications work, but in-app messages never show up

Causes:

  • onMessageReceived does not call handleNotification, or another library's messaging service receives the messages,
  • UserCom.inAppMessagesEnabled is false,
  • the message was sent more than 6 hours before the app was opened.

Fix:

  1. Forward every message to handleNotification, see In-App Messages.
  2. Check where your app sets UserCom.inAppMessagesEnabled.
  3. Test with the app open first, then in the background.

In-app messages do not need the notification permission.

In-app messages sent while the app was closed never appear

Messages sent while the app is in the foreground or in the background appear. With UserCom.debugLogging on, nothing about the lost message appears in the log.

Cause: the SDK is initialized outside Application.onCreate, for example in the first activity. The message starts the app process in the background, only your Application and your messaging service run, and UserCom.default is null.

Fix: move UserCom.initialize to Application.onCreate.

An in-app message appears only after the user leaves the app and returns

Cause: the SDK is initialized after the first activity resumed, for example by a cross platform wrapper, so it does not know the current screen.

Fix: initialize the SDK in Application.onCreate.



Older SDK versions​

On 1.x: the panel shows more clicks than taps

Often after rotations or when users return to the app from recents.

Cause: handleRouteFromNotification in 1.x counted a click every time the activity got the same intent.

Fix: update to 2.0.0. handleNotificationClick counts each push notification once.

On 1.x: in-app messages that arrive while the app is in the background never show up

Fix: update to 2.0.0.

On 1.2.14: Kotlin reports metadata of an incompatible version

Cause: 1.2.14 requires Kotlin 2.0 or later in your app.

Fix: update to 2.0.0, which works from Kotlin 1.8.


Known limitations​

This is how the Android SDK works, not errors in your integration.

  • One device per contact. Push notifications and in-app messages reach only the device that last sent a ping with a push token for that contact. See The contact cannot be selected.
  • Networks that drop idle connections, for example a company VPN, delay Firebase delivery to every app on the device, not only to yours.
  • initialize belongs in Application.onCreate. Anywhere else, in-app messages can be lost while the app is closed or shown late.
  • Your dialogs stay on top of an in-app message. TalkBack can move from the message to your app's content under it.
  • Animated GIFs in in-app messages need Android 9 or later. Older versions show the first frame.
  • One waiting in-app message. The SDK keeps only the newest message it could not show yet, for 6 hours after it arrived.
  • The in-app switch is not saved. UserCom.inAppMessagesEnabled is true at every start, so set it on every launch. See Pausing in-app messages.
  • Email links need domain verification. The app opens from email links only after Positive User publishes assetlinks.json with your package name and fingerprints on your workspace domain. See Email Links.

Contact support​

If the problem persists, contact Positive User support through the chat widget in your workspace or on user.com, or your Customer Success Manager. Include the SDK version, Android version and device model, the contact key from UserCom.default?.userKey, the time of the test, the errors from the callbacks or UserCom.errorHandler, and SDK logs with UserCom.debugLogging on.