简体   繁体   English

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

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

Recently, I've added the stripe_sdk package to my flutter project.最近,我在我的 flutter 项目中添加了 stripe_sdk 包。 The 3DS system requires to add a deep link mechanism to come back to the app when the 3D is OK or KO. 3DS系统需要添加深度链接机制,在3D正常或KO时返回app。

On iOS, I modified my Info.plist to declare the scheme, it works well when I debug and when I deploy the released version via diawi.在 iOS 上,我修改了我的 Info.plist 来声明方案,它在我调试和通过 diawi 部署发布版本时运行良好。

On Android, I modified my android/app/src/main/AndroidManifest.xml to add in intent-filters :在 Android 上,我修改了我的 android/app/src/main/AndroidManifest.xml 以添加 intent-filters :

<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>

No compilation issue, when I debug on simulator or device, no problem.没有编译问题,当我在模拟器或设备上调试时,没问题。 The issue appears when I build a release package using flutter build apk, and distribute it via diawi.当我使用 flutter build apk 构建发布包并通过 diawi 分发它时,就会出现这个问题。 the apk is well download, installation works also, but at the end of the installation, The "Open" button is not active. apk 下载好了,安装也可以,但在安装结束时,“打开”按钮没有激活。 The app is not present with others apps.该应用程序不存在于其他应用程序中。 If I go to parameters -> Applications, I can find my app, but the "open" button is also inactive.如果我转到参数 -> 应用程序,我可以找到我的应用程序,但“打开”按钮也处于非活动状态。 I can only uninstall my app.我只能卸载我的应用程序。 PS : The issue is exactly the same if I upload directly my apk without using diawi. PS:如果我不使用diawi直接上传我的apk,问题是完全一样的。

I tried to modify the scheme and host, and the result is always the same : unable to open my app.我试图修改方案和主机,结果总是一样:无法打开我的应用程序。

If I modify my AndroidManifest.xml to remove the BROWSABLE category and rebuild the package, all becomes OK again.如果我修改我的 AndroidManifest.xml 以删除 BROWSABLE 类别并重建包,一切都会再次正常。 The app can be launched.该应用程序可以启动。

What can be the issue ?可能是什么问题?

Thanks, Luc谢谢,卢克

My full AndroidManifest.xml :我的完整 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>

The standard launcher intent in Android does not include a URI, so it will not match the combined filter . Android 中的标准启动器 Intent 不包含 URI,因此它不会匹配组合过滤器

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 或 MIME 类型时,既不包含 URI 也不包含 MIME 类型的意图通过测试。

In order to accept both the launcher intent and an ACTION_VIEW intent for your URI scheme, MainActivity will need two intent filters:为了同时接受启动器意图和 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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将AndroidManifest.xml添加到Project后如何将应用程序部署到移动设备 - How to deploy an app to mobile after adding AndroidManifest.xml to Project 在AndroidManifest.xml中添加“ @android:style / Theme.Dialog”后,我的Android应用崩溃 - My Android app crashes after adding “@android:style/Theme.Dialog” in the AndroidManifest.xml 我的AndroidManifest.xml有什么问题? - What is wrong with my AndroidManifest.xml? ActivityNotFoundException用于在我的AndroidManifest.xml中声明的活动 - ActivityNotFoundException for an activity declared in my AndroidManifest.xml 如何查看我的包的AndroidManifest.xml? - How to see AndroidManifest.xml of my packages? 我的 AndroidManifest.xml 充满错误,为什么? - My AndroidManifest.xml is full of errors, why? Flutter/Dart - 我的 AndroidManifest.xml 中的这些红色字母是什么意思? 他们是错误吗? - Flutter/Dart - What do these red letters in my AndroidManifest.xml mean? Are they errors? 如何解决我的 flutter 应用程序的 androidmanifest.xml 中的此 firebase 消息传递错误? - How do I resolve this firebase messaging error in the androidmanifest.xml of my flutter application? Cordova 9并未从我的自定义插件向AndroidManifest.xml添加服务标签 - Cordova 9 is not adding service tag into AndroidManifest.xml from my custom plugin 将 firebase 消息传递服务添加到我的 AndroidManifest.xml 文件时,清单合并失败并出现多个错误 - Manifest merger failed with multiple errors when adding firebase messaging service to my AndroidManifest.xml file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM