question

TimReynolds-9947 avatar image
0 Votes"
TimReynolds-9947 asked CharlesWinters-6185 answered

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://docs.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









dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TimReynolds-9947 avatar image
1 Vote"
TimReynolds-9947 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CharlesWinters-6185 avatar image
0 Votes"
CharlesWinters-6185 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.