androidapplinksandroid-app-links

Android applinks not working in released build but work correctly from a local install


I have a game that is using applinks. The applinks work fine when running debug and release versions from my computer but don't work for the version downloaded from Google Play. With the Google Play version, I get a dialog asking which app should open the link.

I use "App Signing by Google Play" and understand that the release APK is signed by Google and has a different signature. I've added the SHA-256 certificate fingerprint from the app signing certificate listed on Google Play to my assetlinks.json so it contains the fingerprint from both the local and Google Play versions.

I've also downloaded a derived APK from Google Play and made sure that the fingerprint matches that in the assetlinks.json file.

Here's an example URL, that when clicked in Android should open the app, which it does for a local build, but not in the Google Play version. Instead, I get a dialog asking which app should open the link.

https://letsdraw.fun/ec?parent=Z0ibN7m-H8jO1jCiMRQtY23VTpKjnIch

I'm writing out the SHA256 fingerprint in logcat from the live release version to double check it's correct and it all looks fine.

The original signed APK and Google Play signed APK can be downloaded from here. Both of these APKs were downloaded from Google Play, one "original" and one "derived", so they should be identical apart from the signing. Interestingly, they're slightly different sizes. 11,590,297 bytes vs 11,601,619 bytes.

Looking at the output from adb shell dumpsys package domain-preferred-apps the original signed apk is

  Package: com.scribble.exquisitecorpse
  Domains: letsdraw.fun scribble-cloud.appspot.com scribble-cloud-v24-test-dot-scribble-cloud.appspot.com
  Status:  always : 200000000

Whereas the Google Play signed apk is

  Package: com.scribble.exquisitecorpse
  Domains: letsdraw.fun scribble-cloud.appspot.com scribble-cloud-v24-test-dot-scribble-cloud.appspot.com
  Status:  ask

When testing with the test page mentioned by @ymindstorm

https://developers.google.com/digital-asset-links/tools/generator

I get the message

Success! Host letsdraw.fun grants app deep linking to com.scribble.exquisitecorpse.

Do you have any suggestions as to what could be causing this?

Update: I've now reported this to Google as a bug, as I can't work out what's going on. https://issuetracker.google.com/issues/162564916


Solution

  • I got help from Google eventually... it wasn't a bug.

    The build process was merging in the host from the network_security_config.xml file, so even though the AndroidManifest.xml file specified:

            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
    
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
    
                <data android:host="letsdraw.fun" android:pathPrefix="/ec" android:scheme="https" />
                <data android:host="letsdraw.fun" android:pathPrefix="/restore" android:scheme="https" />
            </intent-filter>
    

    The file from the build process specified other hosts too:

            <intent-filter
                android:autoVerify="true">
    
                <action
                    android:name="android.intent.action.VIEW" />
    
                <category
                    android:name="android.intent.category.DEFAULT" />
    
                <category
                    android:name="android.intent.category.BROWSABLE" />
    
                <data
                    android:scheme="http"
                    android:host="scribble-cloud-v24-test-dot-scribble-cloud.appspot.com"
                    android:pathPrefix="/ec" />
    
                <data
                    android:scheme="https"
                    android:host="scribble-cloud.appspot.com"
                    android:pathPrefix="/ec" />
    
                <data
                    android:scheme="https"
                    android:host="letsdraw.fun"
                    android:pathPrefix="/ec" />
    
                <data
                    android:scheme="https"
                    android:host="letsdraw.fun"
                    android:pathPrefix="/restore" />
            </intent-filter>
    

    On this page it states that

    Only if the system finds a matching Digital Asset Links file for all hosts in the manifest does it then establish your app as the default handler for the specified URL patterns.

    The problem was that my test host was not returning the same assetlinks.json file as the other hosts.

    After building your APK, using IntelliJ or Android Studio go to Build | Analyze Apk and open the just built APK to check your hosts are all correct and the assetlinks.json file is returning the correct signatures.

    Why is it merging the manifest file like this? Hopefully, we'll find out here!