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
Go to "Android Options" Uncheck: "Use Fast Deployment (debug mode only)"
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 .
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.
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.
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:
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With