Skip to content
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

InAppBrowserActivity.onCreate NullPointerException - Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference #665

Closed
5 tasks done
ycv005 opened this issue Feb 3, 2021 · 24 comments
Labels
bug Something isn't working

Comments

@ycv005
Copy link
Contributor

ycv005 commented Feb 3, 2021

Environment

Technology Version
Flutter version 1.22.5
Plugin version 5.0 (mater branch from github)
Android version 8.1.0
iOS version NA
Xcode version NA

Device information:

Description

App got crash while running the app.

Expected behavior:
App shouldn't be crash.

Current behavior:

Here is the log from the Firebase Crashlytics-

HIGHLIGHTED ERROR

InAppBrowserActivity.java line 16
com.pichillilorenzo.flutter_inappwebview.InAppBrowser.InAppBrowserActivity.onCreate
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{com.example.app/com.pichillilorenzo.flutter_inappwebview.InAppBrowser.InAppBrowserActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2778)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)
Caused by java.lang.NullPointerException
Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
com.pichillilorenzo.flutter_inappwebview.InAppBrowser.InAppBrowserActivity.onCreate (InAppBrowserActivity.java:16)
android.app.Activity.performCreate (Activity.java:7009)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)
ChromeCustomTabsActivity.java line 18
com.pichillilorenzo.flutter_inappwebview.ChromeCustomTabs.ChromeCustomTabsActivity.onCreate
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{com.example.app/com.pichillilorenzo.flutter_inappwebview.ChromeCustomTabs.ChromeCustomTabsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2778)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)
Caused by java.lang.NullPointerException
Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
com.pichillilorenzo.flutter_inappwebview.ChromeCustomTabs.ChromeCustomTabsActivity.onCreate (ChromeCustomTabsActivity.java:18)
android.app.Activity.performCreate (Activity.java:7009)
android.app.Activity.performCreate (Activity.java:7000)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1214)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2731)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2856)
android.app.ActivityThread.-wrap11 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1589)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:6494)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)

If you need more info let me know.

@pichillilorenzo please fix it before next release of the plugin. Highly appreciated for the fix

@ycv005 ycv005 added the bug Something isn't working label Feb 3, 2021
@slorop41314
Copy link

Same issue here

@pichillilorenzo
Copy link
Owner

@slorop41314 Are you using the latest version available from pub.dev? could you post the error logs here?

@ycv005
Copy link
Contributor Author

ycv005 commented Mar 10, 2021

Plugin version- flutter_inappwebview: ^5.1.0+4
Flutter version- 2.0.1

@pichillilorenzo Hey, I found again a crash on firebase with latest version of the plugin, pleasee have a look at it, if needed, I will share more info from crashlytics

image

@no-response no-response bot removed the answered label Mar 10, 2021
@pichillilorenzo
Copy link
Owner

pichillilorenzo commented Mar 10, 2021

@ycv005 Ok I checked that line of code but it doesn't make any sense to me. It's very strange.
It refers to the Bundle instance used to pass arguments to the InAppBrowser Android Activity when it's started/opened.
It's impossible that it's null because when the InAppBrowser Android Activity it's started, it always contains Bundle data (see InAppBrowserManager.open method in the Java native code), otherwise the InAppBrowser won't work properly.
One thing I can think of is that the InAppBrowserActivity.onCreate is called twice, but there is already a check for that.
How do you use InAppBrowser in your Application? Do you use hide and show methods? Are you calling it from Java native code or from Flutter??
Do you have some reproducible steps? Thanks

@pichillilorenzo pichillilorenzo changed the title Crash found on Firebase Crashlytics on a user device InAppBrowserActivity.onCreate NullPointerException - Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference Mar 10, 2021
@ycv005
Copy link
Contributor Author

ycv005 commented Mar 10, 2021

@pichillilorenzo I have only used InAppWebView widget in my tree. I haven't implemented InAppBrowser and either of their methods. No, I am not calling from Java native code or from flutter.

@pichillilorenzo
Copy link
Owner

You can try new version 5.2.0

@dkunkic
Copy link

dkunkic commented Apr 14, 2021

@pichillilorenzo Hi, I have a similar crash on firebase. 
Upgrading the version didn’t change anything. 
Can you please have a look at the issue.
Screenshot 2021-04-14 at 11 40 09

Plugin version - flutter_inappwebview: 5.3.0
Flutter version - 2.0.3

@pichillilorenzo
Copy link
Owner

@dkunkic This is another issue related to the ChromeSafariBrowser class, please open a new issue and don't comment on different issues.
Also, post the full crash logs and not just a screenshot and a code example that can replicate this issue, otherwise it's impossible to me to help you. Thanks

@ZimmerZhou
Copy link

This can be reproduced by starting InAppBrowserActivity by shell,It may happen in automated testing

@pichillilorenzo
Copy link
Owner

@ZimmerZhou I have automated integration tests and these errors don't occur at all. Could you elaborate more? Make a reproducible example with steps, please.

@ZimmerZhou
Copy link

@ZimmerZhou I have automated integration tests and these errors don't occur at all. Could you elaborate more? Make a reproducible example with steps, please.

Simply run "adb shell am start -n YOUR_PACKAGE_NAME/com.pichillilorenzo.flutter_inappwebview.InAppBrowser.InAppBrowserActivity",BTW,You need to set "exported = true" with InAppBrowserActivity,or you will get a permission error.

@pichillilorenzo
Copy link
Owner

pichillilorenzo commented Apr 22, 2021

@ZimmerZhou Well, you cannot simply start that activity like this. You MUST use the API of this plugin otherwise it won't work and you will have a null pointer exception, that is the correct behavior because if you start it this way, the InAppBrowserActivity will not have the right bundle data to make it work properly.
So, calling the activity in that way is not correct.

@ZimmerZhou
Copy link

@ZimmerZhou Well, that's correct. You cannot simply start that activity like this. You MUST use the API of this plugin otherwise it won't work and you will have a null pointer exception, that is the correct behavior because if you start it this way, the InAppBrowserActivity will not have the right bundle data to make it work properly.
So, calling the activity in that way is not correct.

I agree, but what if we can prevent exception by just adding a toast and finishing activity?

@pichillilorenzo
Copy link
Owner

Nope, if a null pointer exception is occurring, that's the correct behavior and that means you are doing something that is not correct, such as the example you made above. So, in that case, required bundle data is missing to make that activity work properly.
If you are receiving this error from your Dart/Flutter code, please post the code you are using, otherwise, I cannot help you more than this.

@niypoo
Copy link

niypoo commented May 16, 2021

Same issue with me ,
happened many times with different users ,

Screen Shot 2021-05-16 at 7 53 08 PM

@Super-Bin
Copy link

Plugin version- flutter_inappwebview: ^5.3.2
Flutter version- 2.2.0
@pichillilorenzo Hi, I have a similar crash on firebase. 
Upgrading the version didn’t change anything. 
Can you please have a look at the issue.

WX20210811-145622

@nietsmmar
Copy link

I got the same error! :( With lib verison ^5.3.2 and flutter 2.5.3.

Why is this issue closed?

@kamxy
Copy link

kamxy commented Nov 6, 2021

same issue

@macortesn
Copy link

Same issue :(. any update?

@pansitwattana
Copy link

I also got this crash error

flutter_inappwebview: ^5.3.2
Flutter version: 2.2.0

@MustafaGamalAbbas
Copy link

Same issue

@huangsir0
Copy link

same issue

1 similar comment
@nietsmmar
Copy link

same issue

@mkucharski17
Copy link

Same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests