在我的 Flutter 项目中,在 AndroidManifest.xml 中添加 Browsable 类别会使我的应用无法使用

In my Flutter project, adding a Browsable category in AndroidManifest.xml makes my app unusable

最近,我将 stripe_sdk 包添加到我的 flutter 项目中。 3DS系统需要加深link机制,在3D OK或KO时返回app

在 iOS,我修改了我的 Info.plist 来声明方案,它在我调试和通过 diawi 部署发布版本时运行良好。

在 Android 上,我修改了我的 android/app/src/main/AndroidManifest.xml 以添加意图过滤器:

<intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="myapp"
                    android:host="3ds.myapp.fr" />
                

            </intent-filter>

没有编译问题,当我在模拟器或设备上调试时,没问题。 当我使用 flutter build apk 构建发布包并通过 diawi 分发它时出现问题。 apk 可以很好地下载,安装也可以,但是在安装结束时,“打开”按钮未激活。该应用程序不与其他应用程序一起出现。 如果我转到参数 -> 应用程序,我可以找到我的应用程序,但“打开”按钮也处于非活动状态。我只能卸载我的应用程序。 PS : 不使用diawi直接上传apk也是一样的问题

我试过修改方案和主机,结果总是一样:无法打开我的应用程序。

如果我修改我的 AndroidManifest.xml 以删除 BROWSABLE 类别并重建包,一切都会再次恢复正常。该应用程序可以启动。

可能是什么问题?

谢谢, 吕克

我满AndroidManifest.xml :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="fr.myapp">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="myapp"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />

                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="myapp"
                    android:host="3ds.myapp.fr" />


            </intent-filter>

        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.INTERNET" />


</manifest>

Android 中的标准启动器意图不包含 URI,因此它 will not match the combined filter

An intent that contains neither a URI nor a MIME type passes the test only if the filter does not specify any URIs or MIME types.

为了接受启动器意图和 URI 方案的 ACTION_VIEW 意图,MainActivity 将需要两个意图过滤器:

<intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
                
    <category android:name="android.intent.category.BROWSABLE" />
    <data
        android:scheme="myapp"
        android:host="3ds.myapp.fr" />
                
</intent-filter>