Closed dkunkic closed 1 month ago
👋 @dkunkic
NOTE: This comment is auto-generated.
Are you sure you have already searched for the same problem?
Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!
If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.
In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE]
or ios WKWebView [MY ERROR HERE]
keywords.
Following these steps can save you, me, and other people a lot of time, thanks!
It should be impossible that when creating an instance of the ChromeSafariBrowser
, the java.lang.NullPointerException: Attempt to read from field 'com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeSafariBrowserManager.plugin' on a null object reference
could happen.
It doesn't make any sense to me, as a ChromeSafariBrowserManager
native class is always instantiated before starting a new ChromeCustomTabsActivity
, otherwise, it couldn't do that.
Could you post the code you are using about the ChromeSafariBrowser
class? How are you using it? Where do you call it? Thanks
I'm using InAppWebView as a widget, and then in shouldOverrideUrlLoading method, depending on which url I get, I open the browser.
child:
InAppWebView(
initialUrlRequest: URLRequest(
url: Uri.parse(UrlConstants.liveTickerUrl)),
initialOptions: InAppWebViewGroupOptions(
android: AndroidInAppWebViewOptions(
verticalScrollbarPosition:
AndroidVerticalScrollbarPosition
.SCROLLBAR_POSITION_RIGHT),
crossPlatform: InAppWebViewOptions(
supportZoom: false,
useShouldOverrideUrlLoading: true,
)),
onWebViewCreated: (controller) {
webView = controller;
// Hide Progress Indicator
loadingIndicatorVisible.value = false;
},
shouldOverrideUrlLoading:
(controller, navigationActionPolicy) async {
var url = navigationActionPolicy.request.url!;
if (url
.toString()
.trim()
.contains(UrlConstants.aditionUrl.trim())) {
chromeSafariBrowser.open(url: url);
return NavigationActionPolicy.CANCEL;
}
return NavigationActionPolicy.ALLOW;
}),
Hello, I've got the same crash on Android version 7 using ChromeSafariBrowser.
The crash intervene when the host is blocked by an htaccess but working otherwise.
2697-2697/my.app.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.app.dev, PID: 2697
java.lang.RuntimeException: Unable to start activity ComponentInfo{my.app.dev/com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeCustomTabsActivity}: java.lang.NullPointerException: Attempt to read from field 'com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeSafariBrowserManager.plugin' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.NullPointerException: Attempt to read from field 'com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeSafariBrowserManager.plugin' on a null object reference
at com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeCustomTabsActivity.onCreate(ChromeCustomTabsActivity.java:52)
at android.app.Activity.performCreate(Activity.java:6942)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
My code :
ChromeSafariBrowser _browser = new ChromeSafariBrowser();
...
await _browser.open(
url: uri,
options: ChromeSafariBrowserClassOptions(
android: AndroidChromeCustomTabsOptions(
addDefaultShareMenuItem: false,
enableUrlBarHiding: true,
showTitle: false,
toolbarBackgroundColor: Colors.black,
),
ios: IOSSafariOptions(barCollapsingEnabled: true, dismissButtonStyle: IOSSafariDismissButtonStyle.CANCEL),
),
);
Same #794
Hello, I've got the same crash on Android version 7 using ChromeSafariBrowser.
The crash intervene when the host is blocked by an htaccess but working otherwise.
2697-2697/my.app.dev E/AndroidRuntime: FATAL EXCEPTION: main Process: my.app.dev, PID: 2697 java.lang.RuntimeException: Unable to start activity ComponentInfo{my.app.dev/com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeCustomTabsActivity}: java.lang.NullPointerException: Attempt to read from field 'com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeSafariBrowserManager.plugin' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6682) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) Caused by: java.lang.NullPointerException: Attempt to read from field 'com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeSafariBrowserManager.plugin' on a null object reference at com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeCustomTabsActivity.onCreate(ChromeCustomTabsActivity.java:52) at android.app.Activity.performCreate(Activity.java:6942) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6682) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
My code :
ChromeSafariBrowser _browser = new ChromeSafariBrowser(); ... await _browser.open( url: uri, options: ChromeSafariBrowserClassOptions( android: AndroidChromeCustomTabsOptions( addDefaultShareMenuItem: false, enableUrlBarHiding: true, showTitle: false, toolbarBackgroundColor: Colors.black, ), ios: IOSSafariOptions(barCollapsingEnabled: true, dismissButtonStyle: IOSSafariDismissButtonStyle.CANCEL), ), );
Can you please give me more information on how to reproduce the bug. Thanks!
Alright, I tried to reproduce it with the minimum application possible and succeed, but it's a problem really specific, don't know if you want to pass a lot of time on it and don't know if you will be able to reproduce. I will explain.
I used your example on ChromeSafariBrowser and get it working with https://flutter.dev/
Then, I used a local url (I can't give it to you, sorry) totally blocked behind an htaccess. Still working.
Where the crash come is when the url (still a local one) is allowed by the htaccess, but other data (css, js, ...) are all blocked.
I tried it on two differents configurations:
For now, that's all the information that I can give you. But don't hesitate to ask more :)
The app crashes if chrome is not installed on the device. That happens on Samsung devices. #1009
I'm seeing the same issue reported in crashlytics on a variety of devices. Has there been any progress identifying the root cause @pichillilorenzo Looking at the source for ChromeCustomTabsActivity I can see there's a lot of potential for this to be returned as null. I'm not sure how this is set in the Bundle, but it seems if the managerId is not set this will result in an NPE.
Bundle b = getIntent().getExtras();
assert b != null;
id = b.getString("id");
String managerId = b.getString("managerId");
manager = (ChromeSafariBrowserManager) ChromeSafariBrowserManager.shared.get(managerId);
same error here on a variety of android devices. I've put a lot of logs to send to crashlytics and I got none of them. And then I realized that it's happing when the app is launching. And I just started ta have this error more frequently last couple of weeks.
is there any workaround for this ?
Have you tried the latest version of the plugin? There shouldn't be that error anymore
@diegoalex Hello, I would like to follow up your issue. We have been getting the same logs as you recently. Have you updated to the latest version? Do you still get the same crash log?
Thank you in advance.
FATAL EXCEPTION: main Process: com.example.demonews, PID: 30777 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demonews/com.example.demonews.ui.MainActivity}: android.view.InflateException: Binary XML file line #75 in com.example.demonews:layout/activity_main: Binary XML file line #75 in com.example.demonews:layout/activity_main: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3766) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3914) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2417) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loopOnce(Looper.java:238) at android.os.Looper.loop(Looper.java:357) at android.app.ActivityThread.main(ActivityThread.java:8194) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957) Caused by: android.view.InflateException: Binary XML file line #75 in com.example.demonews:layout/activity_main: Binary XML file line #75 in com.example.demonews:layout/activity_main: Error inflating class fragment Caused by: android.view.InflateException: Binary XML file line #75 in com.example.demonews:layout/activity_main: Error inflating class fragment Caused by: kotlin.UninitializedPropertyAccessException: lateinit property viewModel has not been initialized at com.example.demonews.ui.MainActivity.getViewModel(MainActivity.kt:20) at com.example.demonews.ui.Fragments.BreakingNewsFragment.onViewCreated(BreakingNewsFragment.kt:28) at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3147) at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:588) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272) at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:114) at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1455) at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3034) at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2945) at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3148) at androidx.fragment.app.FragmentStateManager.ensureInflatedView(FragmentStateManager.java:410) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:271) at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:142) at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:136) at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:247) at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:226) at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1073) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1001) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.inflate(LayoutInflater.java:686) at android.view.LayoutInflater.inflate(LayoutInflater.java:538) at com.example.demonews.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:66) 2024-02-25 22:23:01.823 30777-30777 AndroidRuntime com.example.demonews E at com.example.demonews.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:60) at com.example.demonews.ui.MainActivity.onCreate(MainActivity.kt:24) at android.app.Activity.performCreate(Activity.java:8575) at android.app.Activity.performCreate(Activity.java:8554) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1419) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3747) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3914) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2417) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loopOnce(Looper.java:238) at android.os.Looper.loop(Looper.java:357) at android.app.ActivityThread.main(ActivityThread.java:8194) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957) 2024-02-25 22:23:01.834 30777-30777 Process com.example.demonews I Sending signal. PID: 30777 SIG: 9
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens and logs. It's always better to open new issues and reference the related ones. Thanks for your contribution.
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
Device information: Samsung - mostly Galaxy A51, Galaxy A50 Huawei Mate 10 Lite, LG Velvet, Sony Xperia XZ Premium
Description
I don't know how to reproduce it, but I get this error on Firebase Crashlytics.
Current behavior: Here is the log from the Firebase