Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Cannot reach Android namespace from my common project

When using method
var pathFile = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads);
I cannot suddenly reach the Android namespace.
I made an app 3 days ago going fine but tried creating new and suddnly I get issues when using above?
What can have happened?
Regards KariTall


  • JarvanJarvan Member, Xamarin Team Xamurai

    but tried creating new and suddnly I get issues when using above

    Where did you call the command? Did you add the code in a Xamarin.Forms project? If so, please move the code to the Android platform. This is because the file accessing method is from Android native libraries which we can not use in Xamarin.Forms directly. To solve this, try to achieve the function in the Android project and then use DependencyService to execute the code in Xamarin.Forms.

  • jmatherjmather USMember ✭✭

    Try this:

    var pathFile = global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryDownloads);

    If you created a project with ".Android" in the name or you created a user-defined namespace containing ".Android", then there may be a conflict between your namespaces and the system namespaces. "global::" allows you to explicitly reference the namespace you want from the root.

    To avoid this problem, many devs use "Droid" rather than "Android" in project and namespace names.

    More info:

Sign In or Register to comment.