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

Java.Lang.NullPointerException: uri #136

Open
Simoo23 opened this issue Nov 5, 2024 · 1 comment
Open

Java.Lang.NullPointerException: uri #136

Simoo23 opened this issue Nov 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Simoo23
Copy link

Simoo23 commented Nov 5, 2024

Description

Hello,
I saw sometimes in AppCenter these 2 errors:

Error 1:
mono.java.lang.RunnableImplementor.run
Java.Lang.NullPointerException: uri

Stacktrace:

Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualObjectMethod(JniObjectReference , JniObjectReference , JniMethodInfo , JniArgumentValue* )
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeNonvirtualObjectMethod(String , IJavaPeerable , JniArgumentValue* )
Android.Content.ContentResolver.OpenInputStream(Uri )
NativeMedia.MediaFile.PlatformOpenReadAsync()
NativeMedia.MediaFile.OpenReadAsync()
App.Services.PhotoService.MediaFileService.ReadPhotoAsync(IMediaFile photo)
java.lang.NullPointerException: uri
java.util.Objects.requireNonNull Objects.java:232
android.content.ContentResolver.openInputStream ContentResolver.java:1501
mono.java.lang.RunnableImplementor.n_run(Native Method)
mono.java.lang.RunnableImplementor.run RunnableImplementor.java:31
android.os.Handler.handleCallback Handler.java:938
android.os.Handler.dispatchMessage Handler.java:99
android.os.Looper.loopOnce Looper.java:210
android.os.Looper.loop Looper.java:299
android.app.ActivityThread.main ActivityThread.java:8280
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:576
com.android.internal.os.ZygoteInit.main ZygoteInit.java:1073

Error 2:

androidx.appcompat.app.AlertDialog_IDialogInterfaceOnClickListenerImplementor.onClick
Java.Lang.NullPointerException: uri

Stacktrace:

Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualObjectMethod(JniObjectReference , JniObjectReference , JniMethodInfo , JniArgumentValue* )
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeNonvirtualObjectMethod(String , IJavaPeerable , JniArgumentValue* )
Android.Content.ContentResolver.OpenInputStream(Uri )
NativeMedia.MediaFile.PlatformOpenReadAsync()
NativeMedia.MediaFile.OpenReadAsync()
App.Services.PhotoService.MediaFileService.ReadPhotoAsync(IMediaFile photo)
java.lang.NullPointerException: uri
java.util.Objects.requireNonNull Objects.java:245
android.content.ContentResolver.openInputStream ContentResolver.java:1508
androidx.appcompat.app.AlertDialog_IDialogInterfaceOnClickListenerImplementor.n_onClick(Native Method)
androidx.appcompat.app.AlertDialog_IDialogInterfaceOnClickListenerImplementor.onClick AlertDialog_IDialogInterfaceOnClickListenerImplementor.java:31
androidx.appcompat.app.AlertController$ButtonHandler.handleMessage AlertController.java:167
android.os.Handler.dispatchMessage Handler.java:106
android.os.Looper.loopOnce Looper.java:226
android.os.Looper.loop Looper.java:313
android.app.ActivityThread.main ActivityThread.java:8663
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:571
com.android.internal.os.ZygoteInit.main ZygoteInit.java:1135

Expected behavior

No errors

Steps to reproduce the behavior

I have not reproduced the problem on my devices

Configuration

Plugin Version: 2.2.1

I saw in devices with:

  • Device: Redmi Note 9

  • OS Version: Android 12

  • Device: Galaxy A31

  • OS Version: Android 12

  • Device: moto g04s

  • OS Version: Android 14

and other Xiaomi phones

@Simoo23 Simoo23 added the bug Something isn't working label Nov 5, 2024
@dimonovdd
Copy link
Owner

I have only 1 suggestion: Add logs before await MediaGallery.PickAsync(...) and before await mediaFile.PlatformOpenReadAsync().

You should check if the activity instances are different from Microsoft.Maui.ApplicationModel.Platform.CurrentActivity

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

2 participants