Help! Deep linking on Android in detached ExpoKit


I have an Expo project (SDK v25) that uses deep linking for passwordless authentication (they enter an email, the app sends a login email with a magic link in it, they click the link and it forwards them into the app via a deep linking scheme). It worked fine prior to detaching (so that I could support in-app purchases). iOS continues to work fine, but for whatever reason Android continues to be finicky. Here are the steps to reproduce:

  1. Run the app
  2. Enter email, app sends email to server, server sends email to user, user prompted to open email
  3. Open email, click link
  4. Link launches a second instance of the app
  5. App tries to run, then errors with “Duplicate analytics client created with tag 0…”

I’m convinced it has something to do with the AndroidManifest.xml file, but not being an Android expert has me scratching my head. Any advice?


And just like that, I figured out the issue - documenting below for whoever follows this weary road full of loathing and self-doubt (and for those who know far more about this than I do to let me know what I’m still doing wrong):

When you detach to expokit, AndroidManifest.xml gets a number of relatively sensible defaults for the various ways the app can be launched. The .LauncherActivity section is where deep linking instructions are set up as intent-filters. Android seems to treat the app as two separate instances when deep linked vs. launched from the home screen, which results in the duplicate analytics bug rearing its ugly head. To avoid this issue, modify AndroidManifest.xml by copying the block out of the <activity android:name=".MainActivity"> and paste it into the <activity android:name=".LauncherActivity"> instead.

The other adjustment I made was to add the android:launchMode="singleTask" entry to this .LauncherActivity block as well.

My AndroidManifest now looks (in part) like this:

      android:launchMode="singleTask" <!-- More on this line in a minute -->
        <data android:scheme="myappscheme"/>

        <action android:name="android.intent.action.VIEW"/>

        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="myexpodevscheme"/>

        <action android:name="android.intent.action.VIEW"/>

        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
      <!-- This is the bit that I copied from lower in the AndroidManifest.xml file-->
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>


<!-- I have commented out the <activity android:name=".MainActivity"> block a few lines below -->

Hopefully this helps someone else!

closed #3

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.