-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Crash on webview start. #357
Comments
Unfortunately, I cannot reproduce this error. Have you tried to clean your project? Then, let me know! Thanks |
Yes, I've tried |
I just tested on Android 9 (real device) and Android 10 (simulator) and it works fine! import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(new MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
InAppWebViewController webView;
String url = "";
double progress = 0;
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('InAppWebView Example'),
),
body: Container(
child: Column(children: <Widget>[
Container(
padding: EdgeInsets.all(20.0),
child: Text(
"CURRENT URL\n${(url.length > 50) ? url.substring(0, 50) + "..." : url}"),
),
Container(
padding: EdgeInsets.all(10.0),
child: progress < 1.0
? LinearProgressIndicator(value: progress)
: Container()),
Expanded(
child: Container(
margin: const EdgeInsets.all(10.0),
decoration:
BoxDecoration(border: Border.all(color: Colors.blueAccent)),
child: InAppWebView(
initialUrl: "https://flutter.dev/",
initialHeaders: {},
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
debuggingEnabled: true,
)
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {
setState(() {
this.url = url;
});
},
onLoadStop: (InAppWebViewController controller, String url) async {
setState(() {
this.url = url;
});
},
onProgressChanged: (InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress / 100;
});
},
),
),
),
ButtonBar(
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Icon(Icons.arrow_back),
onPressed: () {
if (webView != null) {
webView.goBack();
}
},
),
RaisedButton(
child: Icon(Icons.arrow_forward),
onPressed: () {
if (webView != null) {
webView.goForward();
}
},
),
RaisedButton(
child: Icon(Icons.refresh),
onPressed: () {
if (webView != null) {
webView.reload();
}
},
),
],
),
])),
),
);
}
} If you try my basic example, does it work for you? |
Also, try to run |
No, it does not work. Same crash. Here is my output of
|
@RomanKapshuk Mmm ok. So, let's try this: Use flutter_inappwebview:
git:
url: https://github.com/pichillilorenzo/flutter_inappwebview.git
ref: master Then, launch my code example again and post here the FULL logs (from start to the end) that you are receiving in Android Studio @Phearun99, if you want, you can also help us to test it! Thanks! |
@RomanKapshuk Also, can you post here your |
Manifest: <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="package">
<uses-permission
android:name="android.permission.RECORD_AUDIO"
tools:node="remove" />
<application
android:name=".Application"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="label"
android:roundIcon="@mipmap/ic_launcher_round">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@style/LaunchTheme"
tools:replace="android:theme" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true"
android:theme="@style/LaunchTheme"
tools:replace="android:theme">
<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="@string/scheme" />
</intent-filter>
</activity>
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:enabled="true"
android:permission="android.permission.INSTALL_PACKAGES">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest> Log:
|
Ok I understand what is causing the problem! Make sure to copy ALL the logs and paste it here. Thanks again! |
@RomanKapshuk However, it seems that Try to add this tag: <meta-data
android:name="flutterEmbedding"
android:value="2" /> inside the <application
android:name=".Application"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="label"
android:roundIcon="@mipmap/ic_launcher_round">
<!-- 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> in your An example is: <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutterapp">
<!-- 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. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="flutterapp"
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"/>
</intent-filter>
</activity>
<!-- HERE IS THE TAG: -->
<!-- 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>
</manifest> Also, remember that you need to call Future main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(new MyApp());
} Let me know if it works now! Thanks. |
@RomanKapshuk @Phearun99 It seems that adding: <meta-data
android:name="flutterEmbedding"
android:value="2" /> inside the |
@pichillilorenzo Thanks. Looks like migration to flutterEmbedding v2 fixed the problem. |
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. |
Environment
Flutter version: 1.17
Plugin version: 3.2.0
Android version: Any
iOS version: —
Xcode version: —
Device information: Any real or simulator
Description
Expected behavior: Should open web view on Android (iOS just fine)
Current behavior: Crash on web view start. Plugin v2.1.0+1 works fine.
Steps to reproduce
Images:
Stacktrace/Logcat
E/MethodChannel#flutter/platform_views(10176): Failed to handle method call E/MethodChannel#flutter/platform_views(10176): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference E/MethodChannel#flutter/platform_views(10176): at android.view.ViewConfiguration.get(ViewConfiguration.java:447) E/MethodChannel#flutter/platform_views(10176): at android.view.View.<init>(View.java:4806) E/MethodChannel#flutter/platform_views(10176): at android.view.View.<init>(View.java:4948) E/MethodChannel#flutter/platform_views(10176): at android.view.ViewGroup.<init>(ViewGroup.java:659) E/MethodChannel#flutter/platform_views(10176): at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:55) E/MethodChannel#flutter/platform_views(10176): at android.webkit.WebView.<init>(WebView.java:659) E/MethodChannel#flutter/platform_views(10176): at android.webkit.WebView.<init>(WebView.java:604) E/MethodChannel#flutter/platform_views(10176): at android.webkit.WebView.<init>(WebView.java:587) E/MethodChannel#flutter/platform_views(10176): at android.webkit.WebView.<init>(WebView.java:574) E/MethodChannel#flutter/platform_views(10176): at android.webkit.WebView.<init>(WebView.java:564) E/MethodChannel#flutter/platform_views(10176): at com.pichillilorenzo.flutter_inappwebview.InAppWebView.InputAwareWebView.<init>(InputAwareWebView.java:28) E/MethodChannel#flutter/platform_views(10176): at com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebView.<init>(InAppWebView.java:559) E/MethodChannel#flutter/platform_views(10176): at com.pichillilorenzo.flutter_inappwebview.InAppWebView.FlutterWebView.<init>(FlutterWebView.java:63) E/MethodChannel#flutter/platform_views(10176): at com.pichillilorenzo.flutter_inappwebview.InAppWebView.FlutterWebViewFactory.create(FlutterWebViewFactory.java:28) E/MethodChannel#flutter/platform_views(10176): at io.flutter.plugin.platform.SingleViewPresentation.onCreate(SingleViewPresentation.java:179) E/MethodChannel#flutter/platform_views(10176): at android.app.Dialog.dispatchOnCreate(Dialog.java:407) E/MethodChannel#flutter/platform_views(10176): at android.app.Dialog.show(Dialog.java:302) E/MethodChannel#flutter/platform_views(10176): at android.app.Presentation.show(Presentation.java:249) E/MethodChannel#flutter/platform_views(10176): at io.flutter.plugin.platform.VirtualDisplayController.<init>(VirtualDisplayController.java:94) E/MethodChannel#flutter/platform_views(10176): at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:47) E/MethodChannel#flutter/platform_views(10176): at io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:112) E/MethodChannel#flutter/platform_views(10176): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:95) E/MethodChannel#flutter/platform_views(10176): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:59) E/MethodChannel#flutter/platform_views(10176): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226) E/MethodChannel#flutter/platform_views(10176): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/MethodChannel#flutter/platform_views(10176): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631) E/MethodChannel#flutter/platform_views(10176): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#flutter/platform_views(10176): at android.os.MessageQueue.next(MessageQueue.java:326) E/MethodChannel#flutter/platform_views(10176): at android.os.Looper.loop(Looper.java:160) E/MethodChannel#flutter/platform_views(10176): at android.app.ActivityThread.main(ActivityThread.java:6669) E/MethodChannel#flutter/platform_views(10176): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter/platform_views(10176): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) E/MethodChannel#flutter/platform_views(10176): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) E/flutter (10176): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference, null) E/flutter (10176): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7) E/flutter (10176): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18) E/flutter (10176): <asynchronous suspension> E/flutter (10176): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12) E/flutter (10176): #3 AndroidViewController._create (package:flutter/src/services/platform_views.dart:633:54) E/flutter (10176): #4 AndroidViewController.setSize (package:flutter/src/services/platform_views.dart:550:14) E/flutter (10176): #5 RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:175:29) E/flutter (10176): #6 RenderAndroidView.performResize (package:flutter/src/rendering/platform_view.dart:156:5) E/flutter (10176): #7 RenderObject.layout (package:flutter/src/rendering/object.dart:1746:9) E/flutter (10176): #8 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #9 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #10 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:11) E/flutter (10176): #11 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:484:7) E/flutter (10176): #12 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7) E/flutter (10176): #13 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:399:14) E/flutter (10176): #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #15 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #17 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #18 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1248:11) E/flutter (10176): #19 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #20 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #21 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #22 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #23 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #24 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #25 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #26 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:556:15) E/flutter (10176): #27 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #28 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #30 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #31 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #32 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #33 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #34 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #35 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #36 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (10176): #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #38 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3223:14) E/flutter (10176): #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (10176): #40 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:700:15) E/flutter (10176): #41 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1630:7) E/flutter (10176): #42 Pipeline
The text was updated successfully, but these errors were encountered: