Xamarin - Newest version of code not always deployed

This is actually a living bug that until now, they haven't been able to target and completely solve the problem.

Newest version of code not always deployed in Android.

Check out these screenshot below. For simplicity's sake. I will add a version umber just below the Header and say let's start with "v1.1"

Then let's change that version to something else.


You can clearly see the difference. The app is still at v1.1 but our changes is now at v1.2
These issues exists not just updating the UI, but also in code-behinds.
i.e you change something in your code, but your changes did not reflect when you ran the app.

I never look at the problem and went straight away to finding for a solution.

Solution

There are number of tried and tested solutions:
Deleting bin and obj folders. This is the very basic thing but very effective way you can do. Close Visual Studio to make sure bin and obj folders are not in used in background process so you can properly delete them. Then actually deleting the BIN and OBJ folders. Uninstall the app in android, and then run it agian. I can't imagine consuming too much time doing this everytime and this is just a complete waste of time.

I am also using a batch command to delete all BIN and OBJ folders in a solution folder

for /d /r . %%d in (bin,obj) do @if exist "%%d" rd /s/q "%%d"

Which just basically say: for all directories inside this folder that named like bin or obj, and if that exists, quietly delete all contents of that directory and that directory.

The other solution are simple but you have to work on logs and rebuild it from there using MSBUILD.. That's not what we want.

So I read someone is actually changing something in the MainActivity.cs file, but what can that be? Is there something really meaningful in MainActivity.cs file to be changed regularly? I do not know.

So I thought, what if I just change the version number? So going back to old experience in Visual Basic 6 where you the revision number is automatically changed by replacing the 0 to * in revision textbox. In Visual Studio and you're working on the Xamarin.Forms - Android project. There's no UI for changing the revision number but instead, you have to go to AssemblyInfo.cs and change it from there and look at the line where it said

[assembly: AssemblyVersion("1.0.0.0")]

and change the revision number. Remember the format
Major . Minor . Build . Revision

And try to run the app again and you will notice, your changes are now deployed without doing too much work.

Comments