The issue was that my project namespace was Company.Prototype.Android and something was getting confused trying to find Android.Content.PM.Permissions. I changed my namespace to Company.Prototype.PhoneApp and it now compiles.
Xamarin Android Quickstart fails with "namespace 'Content' not found"
Trying to build a Sample / Quick Android app for Xamarin.
When it tries to build, I get an error in my MainActivity
"The type or namespace name 'Content' does not exist in the namespace 'MY NAME SPACE' are you missing an assembly reference?"
pointing to:
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
This is the default app, prior to me making ANY changes to it.
These are the steps I have tried.
- https://learn.microsoft.com/en-us/xamarin/get-started/first-app/?pivots=windows
- After that failed, i did this
- Totally uninstalled everything that "Tools>Android>Android SDK Manager" said was intalled.
- I deleted my project folder
- I rebooted my laptop
- I created a new Xamarin Android project in VS
- It failed, stating that I did not have aapt installed
- I followed all of the guidance which suggested running an android.bat file - this failed saying it was obsolete
- I manually installed the SDK and appropriate tools (see final versions below)
- I still get the same errors.
INSTALLED ENVRIONMENT
Visual Studio 2019 v 16.8.3
Xamarin v 16.8.000.260
Xamarin.Android SDK v 11.1.0.17
Android SDK Platform 28 and 29
Android Platform Tools 30.0.4
Android SDK Build Tools 29.0.2
Android Emulator 30.0.6
Android SDK Tools 26.1.1
SDK Patch Applier v4
2 additional answers
Sort by: Most helpful
-
Charles Winters 6 Reputation points
2022-05-15T11:09:41.437+00:00 I found there is a similar problem with ApplicationName.Mobile. I'm thinking MS's example should have a fully qualified namespace to avoid all of this.
-
Siamak Shamaee 5 Reputation points
2023-03-08T21:41:26.2633333+00:00 It's a bit funny. I got the same error because I called my solution Xamarin.Exercise.
Once I changed it to Exercise only it started to work