Running Android version from Visual Studio loads original code instead

I'm having a strange issue where I created a new solution, and just modified the original Text variable (which is "Welcome to Xamarin Forms!") to "Hello Xamarin" but when I run the app, either in debug or release mode, the original Text message is shown instead. I even tried to change the color of the text, the size of the font and the position, but it still loads the app that was first created instead of the changes I made. I've obviously saved my solution so I don't know where it's finding the old code to load.

I've tried modifying the code a bit more to an example from the 'Creating Mobile Apps with Xamarin.Forms Prev. Ed. 2' so this is my current code:

App.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Xamarin.Forms;

namespace myApp
{
    public class App : Application
    {
        public App()
        {
            MainPage = new Page1();
        }

        protected override void OnStart()
        {
            // Handle when your app starts
        }

        protected override void OnSleep()
        {
            // Handle when your app sleeps
        }

        protected override void OnResume()
        {
            // Handle when your app resumes
        }
    }
}

Page1.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;

using Xamarin.Forms;

namespace myApp
{
    public class Page1 : ContentPage
    {
        public Page1()
        {
            Content = new Label
            {
                Text = "Hello Xamarin",
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center
            };
        }
    }
}

Android MainActivity:
using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace myApp.Droid
{
    [Activity(Label = "myApp", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
        }
    }
}

So even though the Text is "Hello Xamarin" it still just shows the default text when the app was created, and no matter how much I change the code, it still reverts to the original. Anyone know why this is happening?

Tagged:

Answers

  • FilipTodorovicFilipTodorovic USMember

    So I noticed that after plugging in a different Android device and running the project, it properly displays the current code, while on my original device the old code is still displayed when I run the project. I feel like there is some old version of the app hidden on the device that's overriding the new one coming in, even though Visual Studio states that it's removing the old version.

  • AllisterAllister USMember ✭✭

    this is a stab in the dark, but I recall encountering a similar scenario and in that case, for whatever reason, the build dependencies weren't setup. It would show changes on a fresh-install/new-device, but old aspects of the android project would show on devices that had previous installations. As if it was doing a partial deploy. Not sure if this will help you, but thought I'd offer build dependencies/order as one place to look.

Sign In or Register to comment.