Hello! I have a Xamarin Forms application with MVVMCross. I just updated to version 6.2.2. When run Android application, splash activity show correctly. Seconds after, screen change color to black and appear in log this message: No view model association found for candidate view MainActivity. In version 6.2.1 works perfectly. In 6.2.2 work perfectly in iOS.
After the splash should appear the first view of the app
[Activity(Label = "test",
MainLauncher = true,
Icon = "@mipmap/logo",
Theme = "@style/Theme.Splash",
NoHistory = true,
ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashScreen
: MvxFormsSplashScreenActivity<Setup, App, FormsApp>
{
public SplashScreen()
: base(Resource.Layout.SplashScreen)
{
}
protected override Task RunAppStartAsync(Bundle bundle)
{
StartActivity(typeof(MainActivity));
return Task.CompletedTask;
}
}
public class Setup : MvxFormsAndroidSetup<Core.App, FormsApp>
{
#region Methods
protected override IMvxAndroidViewsContainer CreateViewsContainer(Context applicationContext)
{
var viewsContainer =
((FormsApp) Application.Current).LoadViewsContainer(new MvxAndroidViewsContainer(applicationContext));
return (IMvxAndroidViewsContainer) viewsContainer;
}
protected override void InitializeFirstChance()
{
base.InitializeFirstChance();
Core.App.LoadServiceLocator();
}
protected override IMvxFormsPagePresenter CreateFormsPagePresenter(IMvxFormsViewPresenter viewPresenter)
{
var presenter = new MvxFormsPagePresenter(viewPresenter);
Mvx.IoCProvider.RegisterSingleton<IMvxFormsPagePresenter>(presenter);
return presenter;
}
#endregion
}
[Activity(Label = "test", Icon = "@mipmap/logo", Theme = "@style/AppTheme",
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, LaunchMode = LaunchMode.SingleTop, ScreenOrientation = ScreenOrientation.Portrait)]
public class MainActivity : MvxFormsAppCompatActivity
{
static readonly string TAG = "MainActivity";
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
{
Plugin.Permissions.PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.tabbar;
ToolbarResource = Resource.Layout.toolbar;
Forms.Init(this, bundle);
UserDialogs.Init(this);
Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, bundle);
var platformConfig = new PlatformConfig
{
BitmapDescriptorFactory = new CachingNativeBitmapDescriptorFactory()
};
Xamarin.FormsGoogleMaps.Init(this, bundle, platformConfig);
Xamarin.FormsGoogleMapsBindings.Init();
XamForms.Controls.Droid.Calendar.Init();
Rg.Plugins.Popup.Popup.Init(this, bundle);
Plugin.Iconize.Iconize.Init(Resource.Id.toolbar, Resource.Id.sliding_tabs);
base.OnCreate(bundle);
CreateNotificationChannel();
}
Version: 6.2.2
Xamarin Forms 3.3.0.967583
Platform:
What type is MainActivity?
@Cheesebaron > What type is MainActivity?
MvxFormsAppCompatActivity. I edit first message to add MainActivity code.
I have the same warning (No view model association found for candidate view MainActivity) on Mvx 6.2.2 and XF 3.4. @pablogupi why did you close the issue? how was it solved?
I have exactly the same setup as @pablogupi.
What was the solution to this issue?
Given that I'm having a very similar problem, I too would love to know what the fix was. :)
@CmdrBeavis make sure you have done the following:
There shouldn't be anything else you do if you are updating from an older version.
@Cheesebaron First, thanks for the above. Now,
TargetFramework is 9.0.
None of my projects contain a packages.config (and I'm pretty sure they never did.)
And this is my MainActivity class declaration;
[Activity(
Label = "MyMobileApp",
Theme = "@style/MainTheme",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
LaunchMode = LaunchMode.SingleTask)]
public class MainActivity : MvxFormsAppCompatActivity<MvxFormsAndroidSetup<Core.App, UI.App>, Core.App, UI.App>
And yet I'm still getting (MvvmCross.Logging.MvxLog) No view model association found for candidate view MainActivity at runtime. :(
(Can I assume I should take this over to Stack Overflow?)
@CmdrBeavis where is your splash screen?
I don't have one. And in fact, was just wondering; Do I HAVE TO have a splash screen? I mean, I have the first page of my app where people will either click a Login button, or a Register button, but I neither want nor need (as far as I know) a 'Splash Screen.' While we're on the subject, I'm also trying to figure out if I HAVE TO have a Setup class as well because I'd swear that the MvvmCross docs didn't say that I MUST have either. Perhaps I missed something?
I'm trying to use the StarWarsSample as well as the TipCalc app as examples, but I feel like neither may be as 'up-to-date' as one might hope.
I am still facing the same problem For MvvmCross 6.4.2 and Xamarin Form 4.5.0.617
How was the issue closed!
Most helpful comment
I have the same warning (No view model association found for candidate view MainActivity) on Mvx 6.2.2 and XF 3.4. @pablogupi why did you close the issue? how was it solved?
I have exactly the same setup as @pablogupi.