Cannot run AvaloniaSample.Android
joergpichler opened this issue · 12 comments
When I clone the repo, open solution in latest VS Community (17.7.4) and select AvaloniaSample.Android as startup project, it does not show the Android Emulator next to the run button. When I switch startup project to MauiSample it appears.
I do not have issues with running Maui Apps or even the avalonia.xplat template.
Any ideas?
Edit: It seems that for whatever reason <UseMaui>true</UseMaui>
seems to be the culprit. If I add this to a new avalonia.xplat app created from template I have the same behavior that I can no longer see the Android Targets in Visual Studio and thus cannot deploy it
Works fine in Rider. Possibly needs to be reported to the VS studio team.
Apparently it was just fixed some days ago internally - waiting for the fix to be released
https://developercommunity.visualstudio.com/t/Adding-UseMaui-to-NET-Android-app-hides/10386552
Just to bring this to its conclusion: I tried the latest preview version of VS and this issue is actually fixed!
But AvaloniaSample.Android
crashes after startup with System.InvalidOperationException: 'No page was set on the window.'
Do you have a stacktrace? And on which device/emulator have you tested it?
Sorry for the late answer.
Stacktrace
- 0xFFFFFFFFFFFFFFFF in Android.Runtime.JNIEnv.monodroid_debugger_unhandled_exception
- 0x1A in Android.Runtime.JNINativeWrapper._unhandled_exception at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:12,5
- 0x1D in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:23,26
- 0x14 in Microsoft.Maui.Controls.Window.Microsoft.Maui.IWindow.get_Content at D:\a_work\1\s\src\Controls\src\Core\HandlerImpl\Window\Window.Impl.cs:390,4
- 0x41 in Microsoft.Maui.Controls.HotReload.Forms.ElementSelectionManager.PostLivePreviewMutation at D:\a_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\Adorners\ElementSelectionManager.cs:476,6
- 0xD in Microsoft.Maui.Controls.HotReload.Forms.ElementSelectionManager. at D:\a_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\Adorners\ElementSelectionManager.cs:420,6
- 0x6 in Microsoft.Maui.Dispatching.Dispatcher. at D:\a_work\1\s\src\Core\src\Dispatching\Dispatcher.Android.cs:22,24
- 0xE in Java.Lang.Thread.RunnableImplementor.Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36,6
- 0x8 in Java.Lang.IRunnableInvoker.n_Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Java.Lang.IRunnable.cs:84,4
- 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
I tried it in Pixel 5 Emulators for Android 13 & 14
Just to bring this to its conclusion: I tried the latest preview version of VS and this issue is actually fixed!
But
AvaloniaSample.Android
crashes after startup withSystem.InvalidOperationException: 'No page was set on the window.'
Same for me (page was set on the window) when using MediaElement.
Also I have the "not show Android Emulator" problem and cannot start emulator when using
https://github.com/hjam40/Camera.MAUI inside MauiControlHost.
Also x:Name (or Name) not works on Maui Native Control inside MauiControlHost
<avamauictrls:MauiControlHost Grid.Row="1">
<cv:CameraView
x:Name="cameraView"
WidthRequest="400"
HeightRequest="400"
BarCodeResults="{Binding BarCodeResults, Mode=OneWayToSource}"
CamerasLoaded="CameraView_CamerasLoaded"
BarcodeDetected="CameraView_BarcodeDetected"
BarCodeOptions="{Binding BarCodeOpts}"
BarCodeDetectionFrameRate="10"
BarCodeDetectionMaxThreads="5"
ControlBarcodeResultDuplicate="True"
BarCodeDetectionEnabled="True">
</cv:CameraView>
</avamauictrls:MauiControlHost>
Also x:Name (or Name) not works on Maui Native Control inside MauiControlHost
It is expected, you can't use named properties generator on non avalonia controls.
Same for me (page was set on the window) when using MediaElement.
Just to confirm, it's with the sample in this repository?
Also x:Name (or Name) not works on Maui Native Control inside MauiControlHost
It is expected, you can't use named properties generator on non avalonia controls.
Same for me (page was set on the window) when using MediaElement.
Just to confirm the
Y
Also x:Name (or Name) not works on Maui Native Control inside MauiControlHost
It is expected, you can't use named properties generator on non avalonia controls.
Same for me (page was set on the window) when using MediaElement.
Just to confirm, it's with the sample in this repository?
with the sample in this repository? > Yes and no, i tried also to make a new project and try to use maui.camera (zxzing) to scan an qrcode. dont work...
@joergpichler @CastelloBrancoTecnologia tried to reproduce it again.
And found out why I couldn't reproduce it before - the issue is Xaml Hot Reload feature in Visual Studio, that's why it was working fine in Rider. Also, if you disable xaml hot reload in VS, then it works fine - Tools > Options > Debugging > Hot Reload and unchecking the “Enable Hot Reload” checkbox
.
It seems like XAML HotReload source code is not open as usual...
I pushed 11.0-preview3 package version, which should fix it. Please note that it also requires Avalonia 11.0.5 as it has some important bug fixes for this package.
I was having the same issue, turning off hot reload fixes it, but the issue persists for me in 11.0-preview3/11.0.5rc1 with hot reload enabled.