-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App crashed on iOS - Lost connection to device #174
Comments
I'm encountering the same issue. When compiled using xcode i get these errors: Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /Users/user/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappbrowser-1.2.1/ios/Classes/FlutterWebViewFactory.swift, line 25 |
i found the main problem in my project. In my case, this might be unique to my project though. My solution is using older version of flutter_downloader which doesn't use such code (i'm using 1.2.2) |
@TimothyY how did you know that there is a conflict? |
When I take out the inappbrowser plugin the flutter_downloader runs normal. the code line I highlight is just recently added on flutter_downloader 1.3.x version I also open an issue on the flutter_downloader github, because their older version works. Are you using that plugin too? or have you tried compiling with xcode to see if there is extra error recognized by xcode for your case? |
I'm not using flutter_downloader. I'm new to flutter that's why I'm not familiar with xcode compiling. Would you please guide me or send me some links on how to do it? |
|
Thanks @TimothyY, I will try this later and will post the progress here. |
Try the latest version of the plugin. However, this plugin changed its name to |
@pichillilorenzo Should i create new issue, or, just post post messages here? I have same issue, on last ( ^2.1.0+1 ) version. |
@koteezy could you explain your use case for which this happens?? Post all useful information such as Xcode version and iOS version. Also, post the Xcode error logs you get. Thanks! |
Alright, i found scenario when i got this error. If i call
I got crash, with these errors Log
But, if i will use something like this:
I will got result, and everything will works fine. Yea, i know what You say what we need use something like this, and i know that is right:
But, how i say here, that listener just not called. ( i use injectJavascriptFileFromAsset ) Flutter doctor
Plugin version: ^2.1.0+1 |
@koteezy if you use About the crash, it has been fixed in the next major release. I tested this code and it works as expected without errors: import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
Future main() async {
runApp(new MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: InAppWebViewPage()
);
}
}
class InAppWebViewPage extends StatefulWidget {
@override
_InAppWebViewPageState createState() => new _InAppWebViewPageState();
}
class _InAppWebViewPageState extends State<InAppWebViewPage> {
InAppWebViewController webView;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("InAppWebView")
),
body: Container(
child: Column(children: <Widget>[
Expanded(
child: Container(
child: InAppWebView(
initialFile: "assets/index.html",
initialHeaders: {},
initialOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
debuggingEnabled: true,
),
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
controller.addJavaScriptHandler(handlerName: "tracks", callback: (args) {
print(args);
});
},
onLoadStart: (InAppWebViewController controller, String url) {
},
onLoadStop: (InAppWebViewController controller, String url) {
controller.injectJavascriptFileFromAsset(assetFilePath: "assets/js/script.js");
},
),
),
),
]))
);
}
} where <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Flutter InAppWebView</title>
</head>
<body>
<p>Hi</p>
</body>
</html> and var tracks = [1,2,3,4];
flutter_inappwebview.callHandler('tracks', tracks); Xcode logs:
|
@pichillilorenzo I will wait, thanks! |
@koteezy my code example is working for you? |
No.. On android, everything okay, except, specific models like that one, on ios have same issue as i show above, if it help, here my browser:
It works fine only if i use callHandler with delay, like:
|
@pichillilorenzo still shows lost connection to device like @koteezy said or else its added a setTimeout(). I got this error when i run via xcode
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue. |
Hi, I've been encountering this issue where the app crashes on iOS simulator and leaves
Lost connection to device
error message. I haven't tested it on a real iOS device yet.Podfile
pubspec.yaml
Flutter Doctor result:
[✓] Flutter (Channel dev, v1.10.14, on Mac OS X 10.13.6 17G65, locale en-PH)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.39.1)
[✓] Connected device (1 available)
This project was not created via
flutter create -i swift
, hope someone could help me on this. This is the only webview plugin that works really great on our app on Android.The text was updated successfully, but these errors were encountered: