flutter - Flutter url_launcher 未在发布模式下启动 url
问题描述
我不知道由于某种原因url_launcher
(https://pub.dev/packages/url_launcher)从谷歌 Playstore 下载应用程序后无法正常工作。在调试模式下,它按应有的方式工作。但是在 Playstore 上上传应用程序并从那里下载后,url 启动器没有启动任何 url。这是为什么?
import 'package:url_launcher/url_launcher.dart';
onTap: () {
launchURL("https://www.google.com");
},
..............
launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
发布规范.yaml
url_launcher: ^5.7.6
我也加了android.permission.INTERNET
我没有使用最新版本,url_launcher
所以可能使用最新版本可以解决问题,但问题是最新版本 url_launcher
需要最新版本的颤振。升级flutter版本安全吗?由于我的应用程序已经投入生产,我不能冒险引发更多问题
这是我尝试升级到 url_launcher: ^5.7.10
最新版本并运行flutter pub get时得到的
[xxxxx] flutter pub get
Running "flutter pub get" in xxxxx...
The current Flutter SDK version is 1.22.0-9.0.pre.
Because url_launcher >=5.7.7 <6.0.0-nullsafety depends on url_launcher_platform_interface >=1.0.9 <2.0.0-nullsafety which requires Flutter SDK version >=1.22.0 <2.0.0, url_launcher >=5.7.7 <6.0.0-nullsafety is forbidden.
So, because xxxxx depends on url_launcher ^5.7.10, version solving failed.
pub get failed (1; So, because storeifie depends on url_launcher ^5.7.10, version solving failed.)
exit code 1
解决方案
我在使用 Android 11(API 级别 30)时遇到了同样的问题——在软件更新之前一切正常(以及在我运行早期版本的测试设备上)——以下似乎让我走上了正确的轨道 https://developer。 android.com/training/basics/intents/package-visibility#all-apps
我通过在 AndroidManifest.xml 中添加以下内容解决了我的问题(尽管可能没有必要。)
<activity android:name="io.flutter.plugins.urllauncher.WebViewActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:exported="false"/>
仅此一项不起作用,然后我添加到 <manifest ... package="com.example.app" 正下方的行中:
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
推荐阅读
- twilio - 在 twilio 自动驾驶仪中使用 play with collect
- continuous-deployment - 通过 Bitbucket 管道构建 Nest 会抛出 sh: 1: rimraf: not found
- python - 无效的语法 django
- reactjs - Material UI:如何在 ReactJS 中的项目上显示 Modal 一次?
- google-bigquery - Google - BigQuery 位置错误(在 europe-west1 位置找不到数据集)
- cypress - 如果条件有效,则无法有条件地检查 Cypress.io 中的元素
- python - Python udp 游戏服务器冻结
- android - 为什么检查视图显示是否显示奇怪的错误
- javascript - 有人可以指导我如何在 svelte 中刷新 iframe 吗?
- r - 根据第二个数据集中出现的实例数替换更新数据集中的值