Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"The type or namespace name 'App' could not be found" Xamarin Forms

I am trying to create a simple app in Xamarin Android with Xamarin Forms using Visual Studio, however I keep getting this error everytime I try to build. I have double checked my references which should contain the Portable project, as well as made sure I have the latest version of Xamarin.Forms. What could I still be missing that would give this error?

using System;

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using App2;

using Xamarin.Forms.Platform.Android;

namespace App2.Droid
{
    [Activity(Label = "App2", Icon = "@drawable/icon", MainLauncher = true,
    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity :
        global::Xamarin.Forms.Platform.Android.FormsApplicationActivity // superclass new in 1.3
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            LoadApplication(new App()); // method is new in 1.3
        }
    }
}
like image 361
jcbrowni Avatar asked May 10 '17 17:05

jcbrowni


Video Answer


1 Answers

In my case, I found there is a bug with Visual Studio 2017 when making a cross platform Xamarin Form app with the generated code if there is a dash in the filename.

It looks like it tries to snake case the title and then complains about not finding that file.

For example, for "my-project", it starts looking for "my_project" in some areas of the generated code.

Using a project name with no symbols seems to solve the issue.

like image 153
Yahya Uddin Avatar answered Sep 25 '22 23:09

Yahya Uddin