devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Deep link validator fails to load & validate links

Open CodingAleCR opened this issue 7 months ago • 2 comments

<-- Please describe your problem here. Be sure to include repro steps. -->

  1. Create a file ".env" at the root path of your project

    {
        "APPLICATION_ID": "com.my.app.id"
    }
    
  2. Edit your android/app/build.gradle file with this after the plugin section :

    def dartEnvironmentVariables = [];
    if (project.hasProperty("dart-defines")) {
        dartEnvironmentVariables = project.property("dart-defines")
            .split(',')
            .collectEntries { entry ->
                def pair = new String(entry.decodeBase64(), "UTF-8").split("=")
                [(pair.first()): pair.last()]
            }
    }
    

    Still on the build.gradle file, edit the application id defaultConfig like that :

        defaultConfig {
            applicationId dartEnvironmentVariables.APPLICATION_ID
            ...
        }
    
  3. Verify that your application is working well using "--dart-define-from-file" on your run command. Here an example with a custom launch config for VSCode if you are using that IDE (.launch.json file)

    {
          "name": "Android - DEV",
          "request": "launch",
          "type": "dart",
          "program": "lib/main.dart",
          "toolArgs": [
              "--dart-define-from-file", ".env"
          ]
    }
    

Result: Unable to load deep link validator tool.

Reference screen shots:

Image


DevTools version: 2.40.2

CodingAleCR avatar Jun 16 '25 17:06 CodingAleCR

FYI @chunhtai @hannah-hyj

elliette avatar Jul 09 '25 22:07 elliette

I did some investigation into this. To get the app link settings for an Android app, the deep link tool calls:

flutter analyze --android --output-app-link-settings --build-variant={{buildVariant}} {{appPath}}

https://github.com/flutter/devtools/blob/79f0a20e6d42ae63027c932a33a49f431ba89450/packages/devtools_shared/lib/src/deeplink/deeplink_manager.dart#L139-L156

On the flutter_tool side:

I believe the the AndroidAnalyze command likely expects the application ID to be a string, and therefore needs to be updated to handle parsing an environment variable instead (https://github.com/flutter/flutter/blob/8fe76181e34852d78802b1f24e612bded2cecdfe/packages/flutter_tools/lib/src/commands/analyze.dart#L288) I've filed https://github.com/flutter/flutter/issues/179705 for that.

On the DevTools side:

We should at least show an error message to show what has gone wrong instead of an infinite spinner. @chunhtai @hannah-hyj - do either of you have the bandwidth to add better error handling here?


FYI @CodingAleCR and any others who run into this - as a temporary workaround I believe you should be able to hardcode your applicationId in build.gradle when you need to validate deep links for your app and then reset it when you are done.

elliette avatar Dec 10 '25 22:12 elliette