Tim Coulter
Tim Coulter

Reputation: 8927

VS2015 Xamarin.Forms Android App: Debugging is Suddenly Broken

I have a Xamarin.Forms Android app that I have been developing in Visual Studio 2015 for several months.

Until today, I have been able to reliably debug the app in both the Android emulator and on a physical device. Now, suddenly, debugging the app in either of these environments results in numerous exceptions.

For example, during its startup sequence, my app initializes Xamarin Insights:

Insights.Initialize(apiKey, Forms.Context);

This has been working fine for months, but now it throws the following exception:

Java.Lang.SecurityException: ConnectivityService: Neither user 10133 nor current process has android.permission.ACCESS_NETWORK_STATE.

I can work around this exception, either by commenting the above code line or by explicitly assigning permission ACCESS_NETWORK_STATE, but it wasn't necessary previously and I believe it is a red hering, since it is one of numerous new random exceptions that occur when debugging the app in Visual Studio.

I have reverted my codebase to a known working revision (one that is being successfully used by beta testers) and nothing changes.

I have tried restarting Visual Studio and rebooting the computer. I have also tried cleaning the solution (both from within Visual Studio and by physically removing all build artefacts) but none of these efforts have helped.

I am guessing that something has been corrupted in Visual Studio, but in view of the time it takes to reinstall, I am hoping that someone may have a suggestion for a quicker fix.

Upvotes: 1

Views: 181

Answers (1)

Jack Zhai
Jack Zhai

Reputation: 6436

As you said that it works well if you add the "uses-permission" in the Mainfest, if so, do you debug your app in release mode or debug mode?

Like this document here: https://developer.xamarin.com/guides/android/advanced_topics/working_with_androidmanifest.xml/ In the Release build version of the manifest (at obj/Debug/android/AndroidManifest.xml), these permissions are not automatically configured. You could add it from the project property.

enter image description here

Upvotes: 1

Related Questions