Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Android: How to stop Visual Studio from removing the previous version of the app before deploying

I'm migrating an Android app written in Java to Xamarin.

The old app (Java) stores some data in the AccountManager and a SQLite DB and I'm looking to migrate that over to a new format when existing users install the new app (Xamarin) as an update so they won't loose their existing data

I'm looking to test the migration code, so I installed a version of the old app on a physical device and then I deployed the new version (a version higher) to the same device but each time I do that, Visual Studio removes the older app and before installing the new app which makes it impossible to debug the migration code (the AccountManager entry which contains data is nuked the moment the older version is uninstalled before launch).

Some things I did try before posting here:

  • I've enabled "Preserve data/cache between application deploys" (https://forums.xamarin.com/discussion/96902/android-app-keeps-getting-uninstalled)

  • Enabled Fast Deployment

Nothing seems to work - I just need the data preserved between deployments so my migration code has a chance to run.

I'm using Visual Studio 2017 for Mac if that's relevant

like image 877
Jay Sidri Avatar asked Jul 22 '19 08:07

Jay Sidri


People also ask

How do I turn off fast deployment in Xamarin?

Go to "Android Options" Uncheck: "Use Fast Deployment (debug mode only)"

Is Xamarin being deprecated?

In May 2020, Microsoft announced that Xamarin. Forms, a major component of its mobile app development framework, would be deprecated in November 2021 in favour of a new .

How do I remove Xamarin from Visual Studio 2016?

Delete any entries that look like they might be related to Xamarin. For example, anything containing the terms mono or xamarin. Open an administrator cmd.exe command prompt, and then run the devenv /setup and devenv /updateconfiguration commands for each installed version of Visual Studio.

How to fix Xamarin Visual Studio extensions not working on Windows?

Create a new Windows user account. Check if the Xamarin Visual Studio extensions load without error for the new user. If those stored settings do indeed appear to be the problem, you can try backing them up and then deleting them.

How do I clear the cache in Xamarin Visual Studio?

In Explorer, delete any remaining files from the Xamarin Visual Studio extension folders (all versions, including both Program Files and Program Files (x86)): Delete Visual Studio's MEF component cache directory, which should be located in the following location:

How to resolve Xamarin package did not load correctly error?

Reinstall the current stable version of Xamarin using from visualstudio.com. In cases where the above steps do not resolve the "package did not load correctly" error, here are a few more steps to try. Create a new Windows user account. Check if the Xamarin Visual Studio extensions load without error for the new user.


Video Answer


1 Answers

I think there are two different things :

When deploying, Visual Studio never updates but uninstalls, then reinstalls the application. Jonathan Prior explained it in 2017 and it is still the case today. As far as I know there is no way to change that, but this is usually not a problem because you can choose to keep the data (VS uses then adb uninstall -k).

On the other hand, if you build a release APK, and install it with adb install -r, then you are using the exact same update mechanism that will be used to deploy your app on users devices. Your migration code will be executed, if not it just means that it doesn't work.

like image 96
bwt Avatar answered Oct 08 '22 13:10

bwt