UXDivers / Gorilla-Player-Support

This is the public Gorilla Player support website
http://gorillaplayer.com
115 stars 17 forks source link

Gorilla SDK Unable to resolve type #271

Open jt-github opened 6 years ago

jt-github commented 6 years ago

I created a test Xamarin.Forms app just to try out the Gorilla SDK using a custom control and am unable to get it to work. It does work as expected when using old-fashioned debugging on the Android simulator (deploying the app without using Gorilla Player or launching via Gorilla SDK).

I added and am trying to use the FlowListView control NuGet package.

When starting the app, I get the usual Gorilla SDK connection screen and then my app appears with an "Additional SDK configuration needed" popup which, when clicked, yields:

Additional SDK configuration needed The previewed page requires assemblies not available in this player. Please use the Gorilla SDK to include those and get an optimal preview.

I started my app using the following in MainActivity.cs in the OnCreate method:

LoadApplication(UXDivers.Gorilla.Droid.Player.CreateApplication(
     this,
     new UXDivers.Gorilla.Config("Good Gorilla")
     .RegisterAssemblyFromType<DLToolkit.Forms.Controls.FlowListView>()
     )
);

With the following namespace added to the MainActivity.xaml ContentPage: xmlns:flv="clr-namespace:DLToolkit.Forms.Controls;assembly=DLToolkit.Forms.Controls.FlowListView"

And the following XAML:

        <flv:FlowListView x:Name="flowListView" FlowColumnCount="3">
            <flv:FlowListView.FlowColumnTemplate>
                <DataTemplate>
                    <Label Text="{Binding Title}"/>
                </DataTemplate>
            </flv:FlowListView.FlowColumnTemplate>
        </flv:FlowListView>

Yet all I see in the Gorilla logs is:

{"level":"warn","message":"[Server] Unable to resolve type 'DLToolkit.Forms.Controls.FlowListView' with arguments '<no arguments>' and assembly '<UNDEFINED>'.\r\ninfo: Xaml processing warning Summary:\"Namespace and content flv was removed\"; Message:\"Namespace flv (clr-namespace:DLToolkit.Forms.Controls;assembly=DLToolkit.Forms.Controls.FlowListView) not recognized, will be removed along with each reference to it.\" processingIssue=true, issueType=warning, file=C:\\Users\\shdwl\\Downloads\\LiveViewTest\\LiveViewTest\\LiveViewTest\\MainPage.xaml, hasPosition=true, line=6, column=45, position=383, area=Xaml, scope=Req, contextInstanceId=8, targetId=2, sampleDataId=0\r\nwarn: Unable to resolve type 'DLToolkit.Forms.Controls.FlowListView' with arguments '<no arguments>' and assembly '<UNDEFINED>'.\r\n","timestamp":"2018-01-19T18:57:17.490Z"}

I tried adding a Gorilla.json file just for fun, to no avail. I tried all kinds of restarts of the simulator, Gorilla server, Visual Studio, updating NuGet packages, updating Visual Studio, etc. Nada.

Thoughts? Here's the project in all its "glory": LiveViewTest.zip

LeoHere commented 6 years ago

Hi @jt-github, I reviewed your solution and it looks fine. I think you are hitting a bug. For some reason (I still need to investigate it) Gorilla is not automatically generating the list of known assemblies from the project definitions.

As a workaround you can add the Gorilla.json (build action None) file at the root of the shared project. The content of the file should be:

{
  "knownAssemblies": [
    {
      "name": "DLToolkit.Forms.Controls.FlowListView",
      "types": null
    }
  ]
}

Just in case, restart Gorilla Desktop app after adding the file.

With this change Gorilla will stop removing the flv and the FlowListView control. Still you will not see anything since there is no sample data associated to the control.

You will need to add DesignTimeData.json. A possible content could be:

{
  "MainPage.xaml": {
    "List": [
      {
        "Icon": "icon.png",
        "Title": "Some title2"
      },
      {
        "Icon": "icon.png",
        "Title": "Some title2"
      }
    ]
  }
}

And finally change your MainPage.xaml to define the FlowItemsSource="{Binding List}".

After that you should be able to see the FlowListView control in the preview.

jt-github commented 6 years ago

Although I noted that I had already tried that in my post on GitHub, I must have used incorrect formatting or something, because after creating the Gorilla.json file, setting it to build action None, creating the DesignTimeData.json file, restarting Gorilla desktop app, cleaning and rebuilding and running my app, I no longer get the complaint about the SDK needing additional configuration (it sees the assembly!)

So, thank you!

I also figured out that I foolishly forgot to set the DesignTimeData.json file to a Build Action of None (otherwise you get some ugly data template errors in the Gorilla logs).

I do have one possibly dumb question:

What log viewer do you use? Looking that the Gorilla logs in Notepad is hurting my soul and I cannot seem to find a good JSON log viewer to save my life. The ones I’ve tried all want a fully-formed JSON document vs. each line being its own JSON.

Thanks,