Search code examples
androidflutterdeep-linking

Flutter deep link adb local testing error


Im getting the following error after trying to test my deeplinks for android locally using the adb.

adb shell 'am start -a android.intent.action.VIEW \                                          52s
    -c android.intent.category.BROWSABLE \
    -d "http://courtyard.gg/"' \
    gg.courtyard.courtyard_mobile
Starting: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://courtyard.gg/... pkg=gg.courtyard.courtyard_mobile }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://courtyard.gg/... flg=0x10000000 pkg=gg.courtyard.courtyard_mobile }

I followed along every step of the flutter docs for deep links and Im now trying to test it locally.

My app runs three different flavors with different dart entry points, is there any extra configuration needed for that?

This is my main activity tag

<application
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name=".MainActivity"
            android:allowBackup="true"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:exported="true"
            android:fullBackupContent="@xml/backup_rules"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize">
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <!-- Deep Linking -->
            <meta-data
                android:name="flutter_deeplinking_enabled"
                android:value="true" />
            <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="courtyard.gg"
                    android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />

    </application>

Solution

  • After some research I found out the package name is not:

    the package property under tag

    as the flutter docs specify.

    It is by default if you don't have flavors in your app, but in case you have, your "package_name" will be the "application id" of your flavor. More about that here ApplicationId versus PackageName - Android Studio Project Site

    In case you don't know what your package name is you can follow these steps: https://stackoverflow.com/a/74617502/13592374

    Be aware that in this last link, many answers mention that to launch your app from the adb shell you can use commands like:

    adb shell am start -n com.package.name/com.package.name.ActivityName
    

    For this to work with flavors the correct nomenclature would be:

    adb shell am start -n flavor.app.id/manifest.package.name.ActivityName
    

    Hope this helps anyone in the same situation!