I’m trying to create a page that loads images remotely from an ObservableCollection. This works fine on Windows but crashes on Android emulator. I’m using VS 17.11.3. I read on github that this was a problem on 17.3 but it is supposed to be fixed. Is this still a known problem? Any workarounds?
<CollectionView
Grid.Row="4"
ItemsSource="{Binding RecommendedList}"
VerticalOptions="FillAndExpand">
<CollectionView.ItemsLayout>
<GridItemsLayout
HorizontalItemSpacing="5"
Orientation="Vertical"
Span="1"
VerticalItemSpacing="5" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid
Padding="10,0,10,0"
ColumnDefinitions="1*,10,Auto"
RowDefinitions="Auto"
RowSpacing="5">
<Image Grid.Column="0" Aspect="Center">
<Image.Source>
<UriImageSource Uri="{Binding ImgUrl}" />
</Image.Source>
</Image>
<Label
Grid.Column="2"
HorizontalOptions="StartAndExpand"
Text="{Binding Title}" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
Edit 1
The C# code supplying the link is the cause of the error – System.Net.Http.HttpRequestException: ‘Connection failure’
The associated call stack is
0x11 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw C#
0x3E in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess C#
0x2E in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification C#
0xA in System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd C#
0x7 in System.Runtime.CompilerServices.TaskAwaiter<System.Net.Http.HttpResponseMessage>.GetResult C#
> 0x37A in Library.LibraryService.GetRecommmendedReads at C:UsersrichasourcereposLibraryAppMClass1.cs:374,25 C#
0x11 in System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Collections.Generic.List<Library.Recommended>>.AsyncStateMachineBox<Library.LibraryService.<GetRecommmendedReads>d__61>.ExecutionContextCallback C#
0x42 in System.Threading.ExecutionContext.RunInternal C#
0x47 in System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Collections.Generic.List<Library.Recommended>>.AsyncStateMachineBox<Library.LibraryService.<GetRecommmendedReads>d__61>.MoveNext C#
0x2 in System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Collections.Generic.List<Library.Recommended>>.AsyncStateMachineBox<Library.LibraryService.<GetRecommmendedReads>d__61>.MoveNext C#
0x6 in System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.<>c.<.cctor>b__8_0 C#
0xC in Android.App.SyncContext. at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36,19 C#
0xE in Java.Lang.Thread.RunnableImplementor.Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:37,6 C#
0x8 in Java.Lang.IRunnableInvoker.n_Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Java.Lang.IRunnable.cs:84,4 C#
0x8 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22,5 C#
This is shown on github.com – https://github.com/dotnet/maui/issues/1260 but should be solved. I’ve checked the uri’s in question and they are all correct.
6
I’ve changed the design to exclude the image file.