1

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.

4
  • you need to trace back and check what changed between now and yesterday. Did you apply any updates to Visual Studio or Windows? Commented Aug 2, 2016 at 22:31
  • AFAIK nothing changed. One minute everything was working and the next it was broken. How do I check what's changed? Commented Aug 3, 2016 at 4:15
  • Just add the following lime above the application tag in the Manifest. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> Commented Aug 3, 2016 at 7:40
  • @MartinP: Yes, that fixes the example issue that I described but, as I explained, there is a whole sequence of never-seen-before exceptions that have started occurring out of nowhere. Something more serious must be causing these, and I don't understand why new permissions would be required if they have never been required before. Commented Aug 3, 2016 at 17:33

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.