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:
Run the app
Enter email, app sends email to server, server sends email to user, user prompted to open email
Open email, click link
Link launches a second instance of the app
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 -->
<!-- This is the bit that I copied from lower in the AndroidManifest.xml file-->
<!-- I have commented out the <activity android:name=".MainActivity"> block a few lines below -->