fryette / webview_cookie_manager

MIT License
48 stars 52 forks source link

getCookies() without a URL parameter causes NullPointerExceptions #11

Closed Aulig closed 4 years ago

Aulig commented 4 years ago

Steps to reproduce:

Resulting error:

E/MethodChannel#webview_cookie_manager(28148): Failed to handle method call
E/MethodChannel#webview_cookie_manager(28148): java.lang.NullPointerException
E/MethodChannel#webview_cookie_manager(28148):  at android.net.WebAddress.<init>(WebAddress.java:77)
E/MethodChannel#webview_cookie_manager(28148):  at v3.a(PG:1)
E/MethodChannel#webview_cookie_manager(28148):  at v3.getCookie(PG:1)
E/MethodChannel#webview_cookie_manager(28148):  at io.flutter.plugins.webview_cookie_manager.WebviewCookieManagerPlugin.getCookies(WebviewCookieManagerPlugin.java:106)
E/MethodChannel#webview_cookie_manager(28148):  at io.flutter.plugins.webview_cookie_manager.WebviewCookieManagerPlugin.onMethodCall(WebviewCookieManagerPlugin.java:59)
E/MethodChannel#webview_cookie_manager(28148):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:230)
E/MethodChannel#webview_cookie_manager(28148):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#webview_cookie_manager(28148):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/MethodChannel#webview_cookie_manager(28148):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#webview_cookie_manager(28148):  at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#webview_cookie_manager(28148):  at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#webview_cookie_manager(28148):  at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#webview_cookie_manager(28148):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#webview_cookie_manager(28148):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
E/MethodChannel#webview_cookie_manager(28148):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/flutter (28148): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(error, null, null)
E/flutter (28148): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:572:7)
E/flutter (28148): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:161:18)
E/flutter (28148): <asynchronous suspension>
E/flutter (28148): #2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
E/flutter (28148): #3      MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:347:40)
E/flutter (28148): #4      WebviewCookieManager.getCookies (package:webview_cookie_manager/webview_cookie_manager.dart:28:21)
E/flutter (28148): #5      _MyAppState.build.<anonymous closure> (package:webview_cookie_manager_example/main.dart:50:52)
E/flutter (28148): #6      _PlatformCallbacksHandler.onPageFinished (package:webview_flutter/webview_flutter.dart:491:29)
E/flutter (28148): #7      MethodChannelWebViewPlatform._onMethodCall (package:webview_flutter/src/webview_method_channel.dart:41:35)
E/flutter (28148): #8      MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:432:55)
E/flutter (28148): #9      MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:385:33)
E/flutter (28148): #10     _DefaultBinaryMessenger.handlePlatformMessage (package:flutter/src/services/binding.dart:267:33)
E/flutter (28148): #11     _invoke3.<anonymous closure> (dart:ui/hooks.dart:282:15)
E/flutter (28148): #12     _rootRun (dart:async/zone.dart:1190:13)
E/flutter (28148): #13     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (28148): #14     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (28148): #15     _invoke3 (dart:ui/hooks.dart:281:10)
E/flutter (28148): #16     _dispatchPlatformMessage (dart:ui/hooks.dart:156:5)

Apart from this error I love this package! Thanks for your work!

fryette commented 4 years ago

Unfortunately, we cannot provide an implementation for getAllCookies() method on the Android platform. We will restrict getAllCookies() by URL.

clragon commented 1 year ago

is this the reason why getCookies with null as argument returns an empty list? it seems that getting all cookies regardless of domain is not possible.

This isnt mentioned in the doc comment of the function and I just spent quite a while debugging this.