We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Java Lang NullPointerException uriString error on Blazor Hybrid

IJSRuntime calls working on my existing WASM app but isn't working on my Hybrid App, It gives Java.Lang.NullPointerException: uriString error.


Toolbaritems.Add(new ItemModel { Text = "Receipt", TooltipText = "Preview selected order", PrefixIcon = "e-properties-2" });


if (args.Item.Text == "Receipt")
{
//Code for editing - Check that an Order has been selected from the grid
if (selectedPOHeaderID == 0)
{
WarningHeaderMessage = "Warning!";
WarningContentMessage = "Please select an Order from the grid.";
Warning.OpenDialog();
}
else
{
await IJS.InvokeAsync<object>("open", new object[] { "/previeworder/" + selectedPOHeaderGuid + "", "_blank" });
}

Once the function is called, the app ends and gives that exception and I have no idea what it means. I looked it up but couldn't find any explanation to help resolve the problem.

in the console:


**Java.Lang.NullPointerException:** 'Loading...'

**Java.Lang.NullPointerException:** 'uriString'

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.NullPointerException: uriString
[mono-rt] at Java.Interop.JniEnvironment.StaticMethods.CallStaticObjectMethod(JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:line 12890
[mono-rt] at Java.Interop.JniPeerMembers.JniStaticMethods.InvokeObjectMethod(String encodedMember, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniStaticMethods.cs:line 95
[mono-rt] at Android.Net.Uri.Parse(String uriString) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-31/mcw/Android.Net.Uri.cs:line 1164
[mono-rt] at Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebChromeClient.OnCreateWindow(WebView view, Boolean isDialog, Boolean isUserGesture, Message resultMsg) in D:\a\_work\1\s\src\BlazorWebView\src\Maui\Android\BlazorWebChromeClient.cs:line 24
[mono-rt] at Android.Webkit.WebChromeClient.n_OnCreateWindow_Landroid_webkit_WebView_ZZLandroid_os_Message_(IntPtr jnienv, IntPtr native__this, IntPtr native_view, Boolean isDialog, Boolean isUserGesture, IntPtr native_resultMsg) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-31/mcw/Android.Webkit.WebChromeClient.cs:line 650
[mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLZZL_Z(_JniMarshal_PPLZZL_Z callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, Boolean p1, Boolean p2, IntPtr p3) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 396
[mono-rt] --- End of managed Java.Lang.NullPointerException stack trace ---
[mono-rt] java.lang.NullPointerException: uriString
[mono-rt] at android.net.Uri$StringUri.(Uri.java:476)
[mono-rt] at android.net.Uri$StringUri.(Unknown Source:0)
[mono-rt] at android.net.Uri.parse(Uri.java:438)
[mono-rt] at crc64d693e2d9159537db.BlazorWebChromeClient.n_onCreateWindow(Native Method)
[mono-rt] at crc64d693e2d9159537db.BlazorWebChromeClient.onCreateWindow(BlazorWebChromeClient.java:30)
[mono-rt] at zu.addNewContents(chromium-Monochrome.aab-stable-584516321:34)
[mono-rt] at android.os.MessageQueue.nativePollOnce(Native Method)
[mono-rt] at android.os.MessageQueue.next(MessageQueue.java:325)
[mono-rt] at android.os.Looper.loop(Looper.java:142)
[mono-rt] at android.app.ActivityThread.main(ActivityThread.java:6944)
[mono-rt] at java.lang.reflect.Method.invoke(Native Method)
[mono-rt] at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
[mono-rt] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
[mono-rt]
[mono-rt] --- End of managed Java.Lang.NullPointerException stack trace ---
[mono-rt] java.lang.NullPointerException: uriString
[mono-rt] at android.net.Uri$StringUri.(Uri.java:476)
[mono-rt] at android.net.Uri$StringUri.(Unknown Source:0)
[mono-rt] at android.net.Uri.parse(Uri.java:438)
[mono-rt] at crc64d693e2d9159537db.BlazorWebChromeClient.n_onCreateWindow(Native Method)
[mono-rt] at crc64d693e2d9159537db.BlazorWebChromeClient.onCreateWindow(BlazorWebChromeClient.java:30)
[mono-rt] at zu.addNewContents(chromium-Monochrome.aab-stable-584516321:34)
[mono-rt] at android.os.MessageQueue.nativePollOnce(Native Method)
[mono-rt] at android.os.MessageQueue.next(MessageQueue.java:325)
[mono-rt] at android.os.Looper.loop(Looper.java:142)
[mono-rt] at android.app.ActivityThread.main(ActivityThread.java:6944)
[mono-rt] at java.lang.reflect.Method.invoke(Native Method)
[mono-rt] at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
[mono-rt] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
[mono-rt]

What does this mean and how can i fix it ?


1 Reply

BH BharatRam Harikrishnan Syncfusion Team September 19, 2023 02:13 PM UTC

Hi Boot,


Based on the details you provided, we have prepared a Blazor Maui App with the Syncfusion Blazor Grid component and its toolbar support. When the toolbar's Receipt item is clicked, it calls a JavaScript function named "myJsFunction" using the JSRuntime.InvokeAsync method. However, we were unable to reproduce the reported issue. It calls the JS function from C# code without any issues.

 

Please find the following sample for reference: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample741070269

 

Could you please check the above sample and provide us with a step-by-step replication procedure to replicate the issue?


Regards,

Bharat Ram H


Loader.
Up arrow icon