I'm trying to set up a brand new Xamarin Android project where I can use Xamarin.Forms (with .NET Standard 2.0) for the UI and can use Xamarin Live Player to preview XAML/run it. I've been getting a strange error that I don't know how to resolve.
I create a New Project > Cross-Platform App (Xamarin) leaving the default name of "App1". I select a Blank App, with UI Technology set to Xamarin.Forms and Code Sharing Strategy to Portable Class Library (PCL). The moment the solution is generated, I proceed to delete the iOS and UWP projects. I build the project and preview in Xamarin Live Player just fine.
Next, I create Add > New Project to the solution. I select a .NET Standard > Class Library (.NET Standard). I leave the default name as "ClassLibrary1". I click OK. I right-click the ClassLibrary1 project and Manage NuGet Packages..., then browse and install Xamarin.Forms (which is the same version as the PCL, which is 2.4.0.280).
Next, I copy and paste App.xaml and MainPage.xaml from the PCL (named App1 (Portable) into the ClassLibrary1 project.
Next, I delete the App1 (Portable) PCL project. This causes an error in the MainActivity.cs of App1.Android because the reference to App is not found. I right-click and add the ClassLibrary1 reference in App1.Android. Additionally, in MainActivity.cs, I add using ClassLibrary1;
This is what my App1.Android now looks like:
using System;
using ClassLibrary1;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace App1.Droid
{
[Activity(Label = "App1", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
}
The project builds just fine. But when I go to preview it in Xamarin Live Player, I get this weird error message:
The following errors were encountered when building and running your app:
• MainActivity.cs: The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?) • MainActivity.cs: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)
Can anyone tell me anything I can do to fix this error and get Xamarin Live Player to work?
I've additionally, tried doing a NuGet update on everything in the solution (nothing pre-release though) with no success.
I'm running Visual Studio 15.4.2. I've tried going to 15.5 (preview) and have had no luck.