If you were able to deploy and debug just fine to your Android devices via USB before you upgraded to Windows 10, but now they just aren’t showing up, then it’s likely because of the way you are connecting them.
For no good reason that I have found so far, it seems like if you want to do USB debugging on Android devices in Windows 10 then you need to connected them as a Camera, yep that’s right, or n protocol terms, PTP.
Thanks, Microsoft. Not.
Sometimes Visual Studio craps out on us and gives some random errors which can be easily cleared out by restarting it. Unfortunately, this is not one of them.
If you see this error that means that genuinely something is breaking the Android packing process, even if the build may have succeed it.
This means there is not one single problem that causes this, but the good news is that it’s really easy to find out what the problem is.
It should be as easy as switching to your Output window and reading the log of all the steps up to when it failed.
This is the tricky part though. It may well be that you’ve even already done that but couldn’t find anything useful or the error message was too generic. Well then, what you are missing is that you have to set your MSBuild output to Normal verbosity. By default, it’s set to minimal.
In order to do that you go to Tools -> Options -> Projects and Solutions -> Build And Run then find where it says MSBuild project build output verbosity (on Visual Studio 2015 that’s a dropdow) and change it from Minimal to Normal if it isn’t set to that option already.
When I wrote this post my problem was that I named an image on the drawable folder with an illegal character in the file name.
Hopefully now you can find out what your problem is too 🙂
In this post I’m going to show you how to implement a cross-platform PDF viewer using Xamarin.Forms. We are going to focus on Android in this tutorial.
The approach we are going to take is to create a Dependency Service implementation on the Android project which triggers a choice for a external PDF viewing app on the user’s phone.
If you are wondering why not just use an embedded WebView to display PDFs, the short answer is that while it would work on IOS this wouldn’t work on any Android versions prior to Lollipop. Also, from a technical strategy and commercial point it may be more beneficial to allow the users freedom of choice. For more on that, you can read my previous blog post WebView Or External Web Picker? Or, When To Give Users Freedom .
Step 1 – Create the Dependency Service contract
On the PCL or SAP project Xamarin.Forms project, create the following interface:
public interface IPdfViewer
void View(string filePath);
Step 2 – Create the Android implementation
On your Android project, create the following class:
public class PdfViewer : IPdfViewer
public void View(string filePath)
//copy to global
var localFileStore = new LocalFileStore();
Android.Net.Uri uri = Android.Net.Uri.Parse("file:///" + localFileStore.GetGlobalPath(filePath));
Intent intent = new Intent(Intent.ActionView);
intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);
Toast.MakeText(Xamarin.Forms.Forms.Context, "No Application Available to View PDF", ToastLength.Short).Show();