Xamarin.Android re-deploying the application does

2019-04-09 20:12发布

问题:

I'm using multiple test devices for development - Nexus 5 and Nexus S.

Didn't have any problem with the Nexus 5, but the S one seems to be having a problem.

protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.Main);

            Button button = FindViewById<Button> (Resource.Id.myButton);
            button.Click += delegate
                {
                    Authenticate();
                };
        }

This code breaks on the Nexus S, which finds the button to be null. Thus I'm assuming it's not generating my layout properly or quickly enough.

I have tried adding a simple null check, but the application appears to be completely ignoring it and using the old assembly. Thus it looks like on an older device the assemblies are not auto-replaced when you're deploying.

Has anyone experienced this? What would be the fix?

EDIT: The API level of the Nexus S is API 16

EDIT: Launched it via Visual Studio, "Deploy" configuration setting was ticked off, so I assume that was the cause of it not refreshing. Is there a setting in Xamarin that automatically resets it at some point?

回答1:

Try uninstalling the application manually from the device and debugging/deploying it again.