如何解决在我的Flutter项目中,在AndroidManifest.xml中添加可浏览类别使我的应用无法使用
最近,我已经将stripe_sdk包添加到我的Flutter项目中。 3DS系统需要添加深度链接机制,以便在3D正常或正常时回到应用程序。
在iOS上,我修改了Info.plist来声明该方案,当我调试和通过diawi部署发布的版本时,它可以很好地工作。
在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>
没有编译问题,当我在模拟器或设备上调试时,没有问题。 当我使用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。
不包含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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。