Google maps 颤振URL启动器谷歌地图崩溃应用程序
几天前,谷歌地图和苹果地图都发布得非常好。在主频道上,我将颤振更新到了最新版本1.13.1。我想在更新后它就停止工作了。所以我把频道改为beta版,并尝试了一下,但仍然不起作用。当尝试启动谷歌地图或苹果地图时,IOS应用程序崩溃,我既不理解错误,也没有在互联网上找到任何东西 非常感谢您的帮助 我的用户界面代码:Google maps 颤振URL启动器谷歌地图崩溃应用程序,google-maps,url,flutter,dart,crash,Google Maps,Url,Flutter,Dart,Crash,几天前,谷歌地图和苹果地图都发布得非常好。在主频道上,我将颤振更新到了最新版本1.13.1。我想在更新后它就停止工作了。所以我把频道改为beta版,并尝试了一下,但仍然不起作用。当尝试启动谷歌地图或苹果地图时,IOS应用程序崩溃,我既不理解错误,也没有在互联网上找到任何东西 非常感谢您的帮助 我的用户界面代码: 列表砖( 标题:Text(“启动谷歌地图”,textAlign:textAlign.center), onTap:()异步{ 最终字符串clubName= clubs[index].n
列表砖(
标题:Text(“启动谷歌地图”,textAlign:textAlign.center),
onTap:()异步{
最终字符串clubName=
clubs[index].name.toString().replaceAll(“,”+”);
打印(“名称:$clubName”);/“完美+俱乐部”
最终字符串clubCity=clubs[index].statt;
打印(“名称:$clubCity”);/“伦敦”
最终字符串newGoogleUrl=
"https://www.google.com/maps/dir/?api=1&destination=$clubName+$clubCity”;
如果(等待canLaunch(新谷歌URL)){
等待发布(新谷歌网址);
}否则{
抛出“无法启动$newGoogleUrl”;
}
},
),
颤振医生-v输出:
[✓] Flutter (Channel beta, v1.12.13+hotfix.3, on Mac OS X 10.15.1 19B88, locale en-DE)
• Flutter version 1.12.13+hotfix.3 at /Library/Flutter
• Framework revision 57f2df76d7 (2 days ago), 2019-12-05 21:23:21 -0800
• Engine revision ac9391978e
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/murat/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.2.1, Build version 11B500
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 35.3.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[✓] VS Code (version 1.40.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.7.0
[✓] Connected device (1 available)
• No issues found!
点击ListTile时出错:
Lost connection to device.
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23c4f02e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50b97b20 objc_exception_throw + 48
2 Foundation 0x00007fff2578c55b -[__NSConcreteURLComponents initWithString:] + 0
3 CoreServices 0x00007fff24e970bd -[_LSURLOverride initWithOriginalURL:checkingForAvailableApplications:newsOnly:] + 151
4 CoreServices 0x00007fff24e97992 -[_LSURLOverride initWithOriginalURL:newsOnly:] + 25
5 CoreServices 0x00007fff24e982ae _ZN14LaunchServices12URLOverridesL20getURLOverrideCommonEP5NSURLb + 399
6 CoreServices 0x00007fff24e9810e -[LSApplicationWorkspace(LSURLOverride) URLOverrideForURL:] + 14
7 UIKitCore<…>
Exited (sigterm)
与设备的连接中断。
***第一次抛出调用堆栈:
(
0 CoreFoundation 0x00007fff23c4f02e例外预处理+350
1 libobjc.A.dylib 0x00007fff50b97b20 objc_异常_抛出+48
2基金会0x000、7FFF2578C55—[α,nStrutURL组件iNITSHITS::] + 0
3 CoreServices 0x00007fff24e970bd-[\u LSURLOverride initWithOriginalURL:checkingForAvailableApplications:newsOnly:+151
4 CoreServices 0x00007fff24e97992-[\u LSURLOverride initWithOriginalURL:newsOnly:][25
5 CoreServices 0x00007fff24e982ae_zn14启动服务12URLROVERRIDESL20GetURLROVERRIDECommonEP5NSURLB+399
6 CoreServices 0x00007fff24e9810e-[LSApplicationWorkspace(LSURLROVERRIDE)URLROVERRIDE FORURRL:+14
7 UIKitCore
退出(sigterm)
根据我的经验,onTap
不能很好地使用async
关键字。我会将逻辑提取到另一个方法中。build
方法甚至不应该包含逻辑,它们应该只用于UI,因为它们应该运行成本低廉,并且可以出于任何原因随时调用
onTap: () => myFunction(clubs, index),
// the function
void myFunction(var clubs, int index) async {
final String clubName = clubs[index].name.toString().replaceAll(" ", "+");
print("Name: $clubName"); // 'Flawless+Club'
final String clubCity = clubs[index].stadt;
print("Name: $clubCity"); // 'London'
final String newGoogleUrl = "https://www.google.com/maps/dir/?api=1&destination=$clubName+$clubCity";
if (await canLaunch(newGoogleUrl)) {
await launch(newGoogleUrl);
} else {
throw 'Could not launch $newGoogleUrl';
}
}
问题解决了
我在我的俱乐部[index].stadt
,这是一个城市列表,城市名称为“ä,ö,ü”
通过添加
最后一个字符串clubCity=clubs[index].statt.toString().replaceAll(“ü”,“ue”);
解决了这个问题。因为,每当在url中调用具有umlaut的城市时,它就会使应用程序崩溃
天哪,这花了我好长时间!我也犯了同样的错误。
我的问题是,我使用的这个url包含了一个航路点的名称
'https://maps.apple.com/?q=“+”$name“+”&ll=$lat,$lon';
如果航路点名称($name
)包含诸如“New York”launch\u url
之类的空格,则不会将空格字符转换为%20
我使用name.toString().replaceAll(“”,“%20”)
修复了它。
完整url示例:
https://maps.apple.com/?q=“+name.toString().replaceAll(”,“%20”)+”&ll=$lat,$lon'
我有完全相同的症状,但我的问题出现在URL的&waypoints=
部分。显然android能够消化以下URL(示例):
https://www.google.com/maps/dir/?api=1&origin=1.11,-0.123和目的地=2.22,-0.456和航路点=1.11,-0.123 | 1.67,-0.245 | 2.22,-0.456和旅行模式=驾驶和方向动作=导航
而对于ios版本,我必须显式地将航路点内的|符号转换为%7C
,因此看起来如下所示:
https://www.google.com/maps/dir/?api=1&origin=1.11,-0.123&destination=2.22,-0.456&waypoints=1.11,-0.123%7C1.67,-0.245%7C2.22,-0.456&travelmode=driving&dir\u action=navigate
尝试使用稳定通道,然后运行flatter clean
。我不能使用稳定通道,因为我至少需要使用Dart SDK版本2.6.0。我有一些依赖项需要Dart SDK版本。嘿,谢谢你发布这个问题。我抛出了相同的错误,但不是针对google maps,而是针对电话号码。电话号码的格式不适合canLaunch和launch函数。它只在IOS Tooya上抛出了错误,不幸的是,错误是code并没有真正的帮助。调试每个值都有助于解决这个问题。试试这个:已经阅读了这篇文章。这并不能解决我的问题。这正是作者实现谷歌地图的方式。我的问题不同。我需要使用URL启动器来启动谷歌地图来给我一个方向。我以前使用过它,但现在不行。StiLH:谢谢你的帮助!如果你使用了“”,它会工作还是仍然崩溃?不幸的是,它仍然崩溃。在try-catch语句中环绕launch
,并打印错误(如果有)谢谢,这也很有帮助。不幸的是,错误代码中没有任何内容,但问题已经解决:)Wie sagt man“`holy cow”“?:-)