dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.2k stars 1.75k forks source link

Problem Geocoding Address #11756

Closed mancda closed 1 year ago

mancda commented 1 year ago

Description

Using VS 2022 ver 17.4.2 and deploying my Maui app to my physical device (Microsoft Duo 1), I am getting System.NullReferenceException Message=Object reference not set to an instance of an object

using the following code

string address = "Microsoft Building 25 Redmond WA USA"; var m = await Geocoding.Default.GetLocationsAsync(address);

Thanks for your help

Steps to Reproduce

See above

Link to public reproduction project repository

This should be readily reproducible without

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android platform 12

Did you find any workaround?

No

Relevant log output

No response

ghost commented 1 year ago

Hi @mancda. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

drasticactions commented 1 year ago

MauiProgram.zip

I tried to repro it on the newest MAUI stable and I couldn't. Does my project run for you @mancda?

janseris commented 1 year ago

For me it's it's missing MapServiceToken message on Windows and on Android 12 emulator it's "grpc call failed" error message. VS 17.4.0 Sony Xperia 5 II Android 12 both functions work 100 %. But no null reference.

Android emulator exception with suspicious part marked in red (D:/a/_work/... is not a path in my PC!) and there is also no user called runner on my Windows machine (seen in /Users/runner/work/s/s/xamarin-adnroid/...: image

at Java.Interop.JniEnvironment.InstanceMethods.CallObjectMethod(JniObjectReference instance, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 11524 at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeAbstractObjectMethod(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 848 at Android.Locations.Geocoder.GetFromLocationName(String locationName, Int32 maxResults) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Android.Locations.Geocoder.cs:line 357 at Android.Locations.Geocoder.<>c__DisplayClass24_0.b__0() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Android.Locations.Geocoder.cs:line 366 at System.Threading.Tasks.Task`1[[System.Collections.Generic.IList`1[[Android.Locations.Address, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__273_0(Object obj) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.Maui.Devices.Sensors.GeocodingImplementation.GetLocationsAsync(String address) in D:\a\_work\1\s\src\Essentials\src\Geocoding\Geocoding.android.cs:line 29 at MauiApp2.GeocodingViewModel.OnGetPosition() in C:\Users\janse\Desktop\prace\Tempus.RSD.RESTAPI\MauiProgram\BaseViewModel.cs:line 68 --- End of managed Java.IO.IOException stack trace --- java.io.IOException: grpc failed at android.location.Geocoder$GeocodeListener.getResults(Geocoder.java:246) at android.location.Geocoder.getFromLocationName(Geocoder.java:215) at android.location.Geocoder.getFromLocationName(Geocoder.java:164) 
ghost commented 1 year ago

Hi @mancda. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 1 year ago

Hi @mancda. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

mancda commented 1 year ago

The program MauiProgram.zip worked fine on my device. I moved the code to a different location in my project and it worked. I have not been able to pin down why it was not working in the first code location.

mattleibow commented 1 year ago

Thanks, I'll close this for now, feel free to open a new issue (or this one again) if it reappears.

Maybe we fixed a bug in a version of maui and then the VS updated to a new version with the fix?