Debugging Xamarin Android apps if I'm using VSTS hosted builds / HockeyApp - visual-studio

I have been developing a Xamarin Android app using Visual Studio Community 2015. So far, everything has been working well for debugging, as I simply build my app in VS, and connect my phone to my laptop and debug it using F5.
Recently, I started using HockeyApp for crash reporting, so that as I'm using my app (during the day when I'm not programming), if it crashes, I can send crash reports. This works OK, but the crash reports don't include line numbers, and also I don't have good references to what build of the app crashed, as the app itself isn't actually getting uploaded to HockeyApp, nor are the debugging symbols.
To help with this, I'm trying to get more organized using Visual Studio Team Services, doing hosted builds upon checkin of my source code, and automatically uploading the app and debugging symbols to HockeyApp.
Now I'm trying to reconcile in my mind how this is supposed to all work for me. If I'm coding in VS and debugging through VS, the app is getting deployed to my phone. But now, I check in the source code, and VSTS does a CI build and uploads everything to HockeyApp. But now, the CI build that VSTS did isn't really the same build that's on my phone, since that build came from the Visual Studio build.
So, when I'm done coding then later in the day, I run my app and it crashes, I'm concerned that the crash report from HockeyApp isn't actually going to relate to what Hockeyapp has. For one, I may not have done a check-in to the source control, in which case, my phone will have a newer version than HockeyApp has. But even if I had remembered to check it in, it's really not the same "build" (since my phone has the APK that was built by Visual Studio and HockeyApp has the APK that was built by VSTS).
Questions:
1) Is there a way to upload my app and debug symbols directly from Visual Studio, without going through a VSTS build? (preferrably automatically upon every build, so that I don't have to remember to do an extra step)?
2) If not, what are the best practices to resolve the issues that I mentioned above?
Ideally, I don't want to have to do any extra steps when I'm done coding for the day. I want to be able to always know that the last version that I built and deployed to my phone will have been uploaded to HockeyApp, so that if it crashes, the crash repo that HockeyApp sends will match with the correct source code and debug symbols.

For your first question, This depends on the project you working on. If you are working on a UWP project, there is an "Enable Crash Analytics" option and "Distribute With Hockey App" option allow you to do this when you right click on the project. But if you are working on a Xamarin.Android project, there is no option to do this. You need to upload them to Hockey App manually. However, you can create a power-shell script to upload these files to Hockey App and configure this power-shell script as post-build event. You can check the power-shell script here for reference: upload_file.ps.
And for the Visual Studio Team Services(VSTS) build, you just need to make sure that the app version and build configuration is totally the same as you debugging through VS from your local machine. Hockey App will detect the version automatically and send the data to the related build version.

Related

Xamarin Form Won't Deploy Visual Studio 2019

I'm new to creating Mobile Android apps using Visual Studio and I've started creating a new Xamarin Forms project. I didn't add any code. I just created it and testing out how it works. When I tried to deploy, it will show an error, "There were deployment errors. Continue?"
Deployment Error
I even went to the Android Device Manager to create an Android Emulator and it also provided me this error.
Android Emulator
I tried every solution that I could find online. Some told me to rebuild, clean and build my solution. That didn't work. I researched to check mark Hyper-V in the Windows features and even rebooting my computer several times and that didn't work. When I tried to deploy, this shows up in the output log. Not sure if this will help.
Output Log
I also attached images of what I've done so far and I really don't know what else to do.
Android SDK Platform and Tools 1
Android SDK Platform and Tools 2
Windows Features 1
Windows Features 2

Share xamarin app with friend for testing

thanks in advance. I've been working on a Xamarin app that I hope to market before too long. It's at the stage where I'd like to share it with one or 2 beta testers on Windows 10. however, I am unable to run the app outside of Visual Studio (where it works fine). When I try to click on the relevant debug or release .exe in Windows Explorer nothing happens. How can I let my beta testers try it without having them install VS and giving them the entire project?
If you have registered a Microsoft developer account and paid for it, then you can add your tester's Microsoft account to the console, then you upload your app to the console, they can see it in the store for testing.
Otherwise, you can make an offline bundle file using the visual studio publish wizard. For more info, see the details.

Visual Studio for Mac creates 2 .apk archives, one with -signed.apk

When I create a release archive of a Xamarin Android app in the latest release of Visual Studio for Mac (8.1.3 build 19), I end up with two .apk's, with filenames like:
com.whatevs.android.apk
com.whatevs.android-signed.apk
Why does it do this? What can I change in my project setup to prevent it? If it can't be prevented, then which one is the appropriate file to upload to Google Play?
This actually used to be a problem a year ago or so, but went away, and now it's back...
The major differences are the debug flag and the signing keys, I guess. You can read more about signing here and manually signing here.
This happen when you build the app and create an archive for publishing with a physical device selected in Visual Studio for Mac as target device.
Select an emulator, Build all and Archive for publishing.

Xamarin workflow on Windows

I'm aware that a Mac or a Mac service e.g. MacInCloud.com is necessary for building and submitting iOS apps.
My question is about the actual workflow of building an app on Windows using Xamarin on Visual Studio 2017.
We need to write code, test and debug throughout development cycle. How does this work with Xamarin running on Windows? How would I actually see what my mobile app looks like or behaves during the actual development cycle?
While developing my web apps in Visual Studio, there are many trips back and forth to the browsers and back to VS in order for me to see the results of my code. How does this work with Xamarin running on Windows? Is Xamarin Live Player the only option for development cycle? Is there a solution through MacInCloud or similar services so that tethering a device to dev machine is not necessary?
I'm just trying to understand how a healthy development cycle is created for Xamarin developers on Windows.
I will answer your question in few section: Coding, Debug, Test
Coding
You will be using Visual Studio to write your codes. iOS and Android code will be written in C#. You will get access to UI Designer for both iOS and Android to edit the layout files and storyboard/xibs. For 3rd party library, there is NuGet to serve your needs.
Debug
You can use Xamarin Live Player without connection to a Mac/MacInCloud for basic preview. However, some features of iOS is not available in Xamarin Live Player (e.g. xibs files not supported...).
If you setup with connection to a Mac, you will be able to see a list of Simulator that available in the Mac you connected to. By default, if you debug it, the simulator will still show up in the Mac. Then you will need to VMWare or remote into the Mac to check the simulator output. If you have Visual Studio Enterprise license, you can get access to a Remote iOS Simulator feature. You will need to turn the option ON. After that, you will able to see a remote iOS Simulator showing in your Windows machine without the needs to remote into Mac machine anymore. For debugging in actual iOS devices, you will still need to plug your device into the Mac. Previously (more than 1 years ago), Xamarin announce that they are working on "iOS USB remoting" to allow you to plug in iOS device into Windows machine and debug on it. But it is not release until now.
For Android, you can get access to Android Emulator Manager to add emulator to debug or you can deploy apps to physical phone just like what you can do with Android Studio.
Test
I will be referring to Xamarin.UITest for this part. You will be able to write UITest code in C# inside Visual Studio. Xamarin have product "Xamarin Test Cloud" to allow you to upload test code and binary and then run your test in cloud periodically. If you want to run the test locally in your machine, you will only able to run Android UITest in windows machine. To run iOS UITest locally, you will only able to run it in Mac machine. Using a Mac, you can also run Android UITest.
You can use a simulator/emulator instead of a device. For iOS, the simulator would run on the Mac Build Host that you are connected to. You can select the option for "Remote iOS simulator" in Visual Studio -> Xamarin.iOS options and you'll be able to interact with the simulator without having to RDP/VNC/look at the mac. For android, you can just run an emulator in Window and interact with it like that. Using your web apps comparison, you would use a simulator/emulator instead of browser but, for the most part, the process would be similar.
I have been developing a Xamarin MVVM app targeted at iOS and Android. I initially did the iOS development on Windows with VS 2022 and an iPhone attached via USB. I knew that I was going to have to eventually move to the Mac for final provisioning but I ended up taking that painful step earlier than planned because certain Xamarin features were just not working on Windows. First I could not get my app icon to be anything other than the Xamarin default and then Xamarin.Essentials.FilePicker would not select a file:
https://github.com/xamarin/Essentials/issues/1710
So after a week of struggling I finally got my project building and deploying on the Mac. However, I am not nearly as comfortable working on the Mac as I am on Windows where I have all my familiar development tools. So then the question was how to share the project files between the PC and the Mac so that I could edit and compile on the PC and then move to the Mac for final testing.
At first I tried iCloud but I could never get the files to sync reliably between the shared folder on the PC and the Mac. I am used to Dropbox and OneDrive, which work as expected. iCloud not so much.
So what I have been doing is committing and pushing the changes to github and then pulling the changes into the project on the Mac. It is quick and has the added benefit of version control using an offsite server. I am happy with this workflow and publishing the app on the Apple Store should be an easy task when that time comes.
Update:
This process is still working for me. I have taken the additional step of doing the release configuration on VS Mac and publishing my app to App Store Connect. That experience was convoluted and frustrating but it now works and I have people testing my app via TestFlight.
One hiccup is that when selecting Automatic iOS Bundle Signing in the project properties on VS Windows, this change gets pushed to the Mac side and causes a build error under Debug until I select the Automatic provisioning profile on the Mac. Somehow it gets set to the Wildcard profile on the Windows side.

Visual Studio for Mac as VSTS build agent for iOS?

Visual Studio is the recommended tool (superseding Xamarin Studio) on both Windows and Mac. However, the VSTS page Build your Xamarin app says to use "Xamarin". Presumably that means Xamarin Studio, even though the the "Install Xamarin" link on the page points to Visual Studio. That ambiguity and the March 6 date on the page indicate that it was overlooked during the rollout of Visual Studio 7 for Mac, leaving us to wonder what is the right approach for setting up an agent.
What is the best way to create an iOS build agent these days? Do you install Visual Studio for Mac or Xamarin Studio?
Sounds like a bit of confusion here in the terminology. The IDE is now Visual Studio for Mac, but the underlying framework is still Xamarin. That is to say, Xamarin.iOS/Xamarin.Android/Xamarin Forms are "integrated" into Visual Studio for Mac; they are the tools that will compile and package your mobile app. This is what the VSTS build task page is saying when it asks you to "Install Xamarin".
As for setting up a VSTS build agent, here's a checklist that will hopefully get you going:
Download and install Visual Studio for Mac on a computer running OS X/macOS. Confirm that Visual Studio for Mac can indeed build and sign the IPA's.
If necessary, install all the certificates and provisioning profiles, and confirm that the IPA is correctly signed.
Create a build project in VSTS.
Install the VSTS build agent for OS X/macOS and connect/register the build agent to the VSTS project. Please be aware that the Xamarin license task/utility is deprecated and no longer needed. If that does appear as a step in your VSTS build project, delete it.
Go back to VSTS, and configure the VSTS project to build the Xamarin.iOS project via the OSX/macOS build agent. Once the build agent is connected to the VSTS project.
I'll admit, there is a lot of moving parts and things to do here. I hope this high level overview is enough to point you in the right direction.
Per starain's advice, I tried installing VS for Mac. It started up, but failed with an 'Unable to parse condition "!(Exists($(SharedVersionOutputDirectory)))"' error. I've encountered several bugs in the Xamarin tool chain, so this may have nothing to do with VS vs. XS, but just be part of the current duct-tape-and-bailing-twine experience. OTOH, there's still a top-level Xamarin page saying VS Mac is still preview, so who knows how baked it really is?
So even though the Mac build agent does find and run the VS Mac build tooling, I gave up and used my Windows build agent instead, and had MSBuild on Windows connect to the Mac for the iOS build.

Resources