在我的Flutter项目中,在AndroidManifest.xml中添加一个可浏览的类别会使我的应用程序无法使用



最近,我将stripe_sdk包添加到了我的flutter项目中。3DS系统需要添加一个深度链接机制,以便在3D正常或KO时返回应用程序。

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

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

<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构建apk构建一个发布包,并通过diawi分发它时,就会出现这个问题。apk是很好的下载,安装也可以,但在安装结束时;打开";按钮未激活。该应用程序不存在于其他应用程序中。如果我转到参数->应用程序,我可以找到我的应用程序,但;打开";按钮也处于非活动状态。我只能卸载我的应用程序。附言:如果我不使用diawi直接上传我的apk,问题是完全一样的。

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

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

问题出在哪里?

谢谢,Luc

我的完整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,因此它与组合过滤器不匹配。

只有在筛选器未指定任何URI或MIME类型的情况下,既不包含URI也不包含MIME类型的意图才能通过测试。

为了接受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>