Visual Studio 2017: Xamarin Projects Not Being Created

Well, I ran into a bit of a problem this morning. I started up Visual Studio 2017 and tried to create a new Xamarin Forms Project targeting Android, iOS and UWP. However, all that happened was a solution file being created, none of the actual projects were created.

Well, that’s not what I want! I did some digging and it seems like during one of my Visual Studio 2017 updates, the Android SDK was removed and not updated. I fired up the Visual Studio installer and installed the latest SDK’s.

Started up Visual Studio again and … success! A new Xamarin Forms project was successfully created. Too bad I didn’t think to try creating a new project targeting just iOS and UWP: perhaps that would have pointed to the Android SDK being the problem quicker.

Hope this helps someone else.

Platform Services: Part 2

Hello from Las Vegas! I am down in Las Vegas for the Autodesk Forge DevCon and Autodesk University. A total of four days of an absolute fire hose of information and learning! I have a few minutes of downtime and I wanted to provide an update on the new direction of consuming platform specific services in your portable project.

In my original post, I showed you how Prism would use the Xamarin Forms built in dependency service to resolve an object if it couldn’t find it in the container that Prism uses. That was the accepted practice for version 6.3 and earlier, but now, in the upcoming 7.0 release, the authors have specified that all object resolution should be done via the Prism container.

Fortunately it is pretty easy.

In Prism, there is an interface that you implement for each of your platforms: IPlatformInitializer where T is your Prism container. I typically use Unity, so my implementation would look something like this:

public class AndroidInitializer : IPlatformInitializer<IUnityContainer>
    public void RegisterTypes(IUnityContainer container)
        container.RegisterType<IPortableInterface, DroidImplementation>();
        // other registrations

Now you just need to pass that implementation into the LoadApplication call in the platform specific app initialization. Continuing with Android, it looks like the following:

[Activity(Label="projectname" ...)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
    protected override void OnCreate(Bundle bundle)
        global::Xamarin.Forms.Forms.Init(this, bundle);
        LoadApplication(new App(new AndroidInitializer()));

From there, it goes into your App object that is derived from your selected container specific PrisApplication class. The constructor takes one parameter of IPlatformInitializer which you just move along to the base constructor.

public class App : PrismApplication
    public App(IPlatformInitializer initializer = null)
        : base(initializer)

    /// ... rest of your implementation

And there you go: all of your registrations controlled directly within Prism for a one stop shop for managing them.

I will add one small caveat to the information above. I wrote most of this from memory while sitting in a hallway at the Sands Convention Center. Prism is going through a number of changes from 6.3 to 7 and I might have mis-spelled a class name. But I think it should stand up fairly well.