Why can't I debug a simple Xamarin app that targets Android? - c#

I am trying to create a simple Xamarin app on my Windows PC targeting Android and it is proving to be a real pain with problems at every single step of the way (no single step was without a lot of pain). I am now at the step where I am trying to start the device as shown below:
When I try to start this device I see the following error:
I have been trying to sort this error for the last 1.5 days with no luck. I have come across this webpage, which talks about the error: https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/android-emulator/troubleshooting?pivots=windows#accel-issues-win
Therefore I run the following command:
"C:\Program Files (x86)\Android\android-sdk\emulator\emulator-check.exe" accel
I see this:
Is this telling me that my CPU is not suitable for Xamarin development? My research is telling me that this is just warning me that debugging could be slower.
I have also come across this: https://visualstudio.microsoft.com/vs/msft-android-emulator/. I have installed it, but don't really understand what it is needed for because the Emulator appears to be installed as part of Visual Studio:
Now see the image below:
Notice I have enabled Hyper-V and Windows Hypervisor Platform.
What is the problem? Please note that I have created a basic HelloWorld type app i.e. using the project defaults.

Related

Hologram is not shown in the hololens 2 while it's working in the desktop

I deploy my HoloLens 2 in Visual Studio through Release, ARM64, and Device. If I use the Release Machine instead of the Device, I got an error.
My desktop doesn't have the same Wi-Fi as my HoloLens. I can't connect my desktop and HoloLens to the same Wi-Fi.
My deploy is succeeded after I use the Device. My project Icon is shown in the HoloLens 2. But after I open the Icon, I can't see anything.
Please help me to find the solution. I spend a lot of time on this problem.
Maybe my explanation of Remote Machine and Device gave you some misunderstanding. I'm sorry about that. Remote Machine + WIFI and Device + USB are both officially recommended deployment methods. Since you have successfully deployed through Device, please continue to use it. If you are still a little confused about deployment you can publish a new thread.
It seems the main issue here is that when you run the deployed project, you cannot see any object. I recommend you try Remote Debugging(https://learn.microsoft.com/en-ca/windows/mixed-reality/develop/unity/preview-and-debug-your-app?tabs=openxr) in the Unity editor, which allows you to quickly preview and debug your project without deployment, and it can also be connected via USB. You can also use the official sample to Remote Debugging or deploy directly. Also, it's important to note that before you build your project in Unity, you need to add the scene to Build Settings->Scenes in Build.
Finally, I found the solution to my problem. Before I used the unity 2020.3.9. Now I changed the version to 2020.3.4. Now I can deploy and see the game objects in my hololens 2.
I had the same issue before. In the unity editor, I can see my models normally. But the models were not shown in Hololens, or only by one eye. The reason was that the models use the standard shader of Unity. After I applied the Mixed Reality Toolkit/ Standard Shaders, every model was shown.

.NET MAUI app doesn't start in Android emulator

I'm new to MAUI so I followed the instructions on Microsoft's Build Your First App page. I ran the Android emulator and everything worked fine.
I then followed this page to build a flashlight app, but when I ran it, the emulator started fine, but the app never loaded.
In the output window in Visual Studio, I saw this:
[mono] debugger-agent: Unable to connect to 10.0.2.2:54762
I created a brand new .NET MAUI app, made no changes and ran that, same result.
I followed the deployment issues section on this page to no avail.
Also, when I ran sdkmanager --update, I got the following output:
[=== ] 10% Computing updates...
Updating:
platform-tools
emulator
Warning: Failed to read or create install properties file.
[=== ] 10% Installing Android Emulator
where it's saying it failed to read/install the properties file.
I also tried Razwill-1930's answer on this page, again, to no avail.
I'm running .NET 6 in Visual Studio 17.3.5 on Windows 11 Pro.
What am I doing wrong?
Update
I downloaded another emulator and that one works fine, which for my purposes, I'm OK with not being able to use the Pixel 6 emulator that gets installed with the .NET MAUI workload in VS. How can I get it going?
I ended up deleting the emulator (Pixel 5 - API 31) and then reinstalling it.
That worked.
Not sure why that worked, the Android Device Manager didn't re-download the files.
Hey, banging the TV sometimes works too.
The issue is with your emulator, I would highly recommend you recreate the emulator. Points to remember when doing so:
Make sure you have the latest version of the API version's Image
Select Arm64 as your processor (has lesser lag).
Hardware-based GUI has better performance.
Just FYI Assigning too much RAM won't make it faster

deploy simple c# app to another computer from Visual Studio 2017

I have written a simple c# app to let my son do some stats on dice rolling for a game he is developing.
I created a simple interface using Visual Studio 2017 and Universal Windows.
After loads of silly errors - and lots of less silly ones, I finally have an app that runs as I want it to in debug mode.
I now want to publish it so he can copy the files and run it on his Windows computer.
Now I am sure this is really easy - but after 2 days of google searching, MSDN searching and searching this forum I am no nearer knowing what I need to do.
I have changed the solution configuration to Release and the platform to x86. I have run Build and Deploy solution form the build menu and have loads of files in my bin/x86/release file partial list from windows explorer.
But none of the exe files seem to do anything (the app5.exe waits a while sometimes, but no sign of the app anywhere).
I am obviously missing some critical preparatory step, but I can't find out what it is.
Some of the MSDN notes talk about Publish (this is greyed out or not present, but Deploy appears).
Can anyone please point me to some idiot proof documentation to help me work out what I should be doing.
I am new to Visual Studio, new to C# and new to windows app development - so my app has been pulled together from web research and using common sense :)
I have assumed that what I am trying to do is pretty easy - but I am not yet convinced.
To sell your Universal Windows Platform (UWP) app or distribute it to other users, you need to package it. If you don't want to distribute your app through Microsoft Store, you can sideload the app package directly to a device. Since you used the VS, you can follow this document to package a UWP app with Visual Studio: https://learn.microsoft.com/en-us/windows/uwp/packaging/packaging-uwp-apps#sideload-your-app-package.
After you package your app, if you want to sideload your app, you can follow the How do I sideload an app on desktop part in the following document:
https://learn.microsoft.com/en-us/windows/application-management/sideload-apps-in-windows-10#how-do-i-sideload-an-app-on-desktop
More details, you can get from this topic:
https://learn.microsoft.com/en-us/windows/uwp/packaging/

How to deploy a compiled application without Visual Studio?

When I open a sample Blinky application in Visual Studio, compile and run it, it gets automatically deployed to the target configured WindowsIoT device. After that, on Windows 10 machine where I compile it, the application binaries are located in the bin sub-folder of the project folder as one would expect.
I would like to automate the deployment, so that I could run deployment code
without Visual Studio, specify target device and the binaries location and it would deploy it. I cannot find any API that allows
to deploy apps to Windows IoT, how do I do that?
This shiny Windows IoT stuff is a new area, and there is not a lot of info available apart from the samples and the getting started page. Any pointers are appreciated.
Update: As noted in comments, once one start thinking of mass production, they will probably need to conciser ICD. This, is not, however the problem I'm trying to solve currently. I would like to figure out how I can provide Over-the-Air updates to my UWP application running on Raspberry Pi and Windows IoT. I also would you like to know how I can automate build / deployment in general, but that may be automatically solved if I have a proper OTA solution.
There is a set of instructions on how to do it, which can be found in the same github repo you are linking in your question, but in a different folder. Note, that you need an appx for these instructions to work, and it's not created by the solution build by default.
This page provide (non IoT specific) instructions on using VS to build the appx. And this blog post talks about the command line tool that can be used for making appx.
Note, that the last two links are also talking about publishing an application to app store, so you'll need to make some mental adjustments around that.

AndroidManifest.xml does not merge activity info upon Build

Pretty new to Mono for Android (C#), and I'm seeming to have trouble during one of their tutorials where it mentions that info on Activities is merged into AndroidManifest.xml upon compilation.
The FirstActivity class is set to Compile upon Build, yet no AndroidManifest file is created. One can be created via the Project menu but it doesn't include any information on Activities and does not update when these are changed.
Had a look around on the internet but I only managed to find issues relating to Visual Studio.
Any help would be appreciated! :) Thanks.
edit: I'm using the evaluation version right now, if that's any problem.
edit: Getting more problems it seems. Had trouble accessing the AVD through Mono and decided to reinstall the Android SDK to the latest version. Attempts to run the program on the emulator cause the 'Devices' list to disappear shortly after emulator startup (or, at the very best, it fails to acknowledge that an emulator is active). running 'adb devices' spits out the correct emulator "emulator-5554" or something, but Mono's just repeatedly failing to notice.
It's correctly pointed to Android SDK and Java as far as I know.
The AndroidManifest.xml that is generated is created in:
obj\Debug\android\AndroidManifest.xml
The one in your project is not touched.

Categories