Higor Pereira
Higor Pereira

Reputation: 175

Missing / Not found Android.App namespace on Maui

I'm trying to migrate my Xamarin project to Maui and I got stuck on finding the equivalent namespace to Android.App.Application.Context on Maui project. The DatabaseHelper class has the following path: MyProject -> Platforms -> Android -> Helpers.

Does anyone know what is the equivalent namespace to Android.App.Application.Context on Maui?

CS0234: The type or namespace name 'App' does not exist in the namespace 'AAT.Platforms.Android' (are you missing an assembly reference?)

Picture of error

Thanks!

Upvotes: 10

Views: 7454

Answers (2)

ToolmakerSteve
ToolmakerSteve

Reputation: 21243

The error message is (indirectly) telling you what is wrong:

The type or namespace name 'App' does not exist in the namespace 'AAT.Platforms.Android'.

This is happening because you are in namespace AAT.Platforms.Android.Helpers, which means that Android is assumed to mean AAT.Platforms.Android.

Here are two ways to access Android.App.Application.Context in this situation:

  • global::Android.App.Application.Context OR

  • using AndroidApp = Android.App.Application;
    AndroidApp.Context

Upvotes: 13

fmaccaroni
fmaccaroni

Reputation: 3916

Try changing your namespace to another thing that doesn't include Android. Because it's trying to find the class inside your namespace instead of the correct one. So I'd advise you to use Droid instead of Android in your namespace, i.e. AAT.Platforms.Droid.Helpers. HIH

Upvotes: 3

Related Questions