I am trying to build a Xamarin Forms project for Surface Duo. The project runs, but will not utilize both screens. I followed the steps at Xamarin for Surface Duo - Dual-screen | Microsoft Docs:
Updated the pointer to the SDK.
Added
Xamarin.Forms.DualScreen.DualScreenService.Init(this);
tomainactivity.cs
.Modified the Activity abbribute to include:
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.UiMode
.Included the Xamarin.DuoSdk package in the Android app.
While reading through the emulator output, one line recommended to turn off hyper-V using bcdedit command, which I did.
Selected
<build>
(Android 10.0 – API 29)
I downloaded some of the samples (Sketch 360 and Dual Screen Demos) with no luck in getting them to use both screens. I ran the demos as posted on Get, and updated the packages, with no luck. I checked the phone settings in the emulator to see if there was a setting to enable both screens, but didn’t find anything. There are some errors, warnings in the emulator output, but not sure how to fix them.
Emulator Output
emulator: Silencing all qWarning(); use qCWarning(...) instead: QT_LOGGING_RULES=default.warning=false
Failed to open /qemu.conf, err: 2
emulator: INFO: QtLogger.cpp:68: Critical: UpdateLayeredWindowIndirect failed for ptDst=(1283, 327), size=(700x21), dirty=(700x108 0, 0) (A device attached to the system is not functioning.) ((null):0, (null))
emulator: INFO: QtLogger.cpp:68: Critical: UpdateLayeredWindowIndirect failed for ptDst=(1283, 327), size=(700x21), dirty=(700x21 0, 0) (A device attached to the system is not functioning.) ((null):0, (null))
emulator: INFO: QtLogger.cpp:68: Critical: Uncaught TypeError: Cannot read property 'update' of undefined (qrc:/html/js/location-mock-web-channel.js:130, (null))
Build Output
System.InvalidCastException: Unable to cast object of type 'Mono.Debugger.Soft.PointerValue' to type 'Mono.Debugger.Soft.PrimitiveValue'.
System.InvalidCastException: Unable to cast object of type 'Mono.Debugger.Soft.PointerValue' to type 'Mono.Debugger.Soft.PrimitiveValue'.
System.InvalidCastException: Unable to cast object of type 'Mono.Debugger.Soft.PointerValue' to type 'Mono.Debugger.Soft.PrimitiveValue'.
02-06 20:34:52.574 W/libc ( 3873): Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
02-06 20:34:54.961 W/OpenGLRenderer( 3873): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
Run the
Surface Duo Emulator for Visual Studio
to start the Surface Duo emulator. If you have any issue about the emulator, you could troubleshoot with the link below. https://learn.microsoft.com/en-us/dual-screen/xamarin/use-emulator?tabs=windows#update-the-pointer-to-your-android-sdkInstall the package via NuGet.
Xamarin.Forms.DualScreen
:https://www.nuget.org/packages/Xamarin.Forms.DualScreenUse the xaml like below.
Run the project with emulator
<build> (Android 10.0 – API 29)