Newest version of code not always deployed when debugging from Xamarin Studio

I have found recently that if I build an run from within Xamarin Studio, the newest version of my code doesn't always get deployed. The code does get rebuilt, and I see the message about deploying to device, but the code that runs isn't always my newest (I have verified this).

The application is a Xamarin.Forms application.

So far, I've only seen this happen on Android. It happens on the Xamarin Android Player and actual devices.

If I rebuild all, or manually delete the app from the device, the newest code deploys.

The date/time of the device and my PC are correct, so it makes me think it's not a timestamp issue.

Has anybody seen this?

Any suggestions on how to fix it?

«1

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    @TimF Yesterday I have not the same thing.
    I have deployed to a POS with a integrated printer. I pressed a button to print some strings but I have seen "old" string go out from the printer.
    I have deleted manually "bin" and "obj" directory and all works fine.

  • TimFTimF USMember

    Thanks @LoriLalonde !

    I tried unchecking Fast Assembly Deployment, but now my app crashes when it tries to run. A stacktrace is being written to my data directory, but unfortunately the handset I'm using isn't rooted, and adb isn't working properly for me, so I can't pull the stacktrace.

    Any ideas?

  • LoriLalondeLoriLalonde CAInsider, University, Developer Group Leader ✭✭✭

    @TimF, try completely uninstalling the application from the device. Clean the solution and debug. If it is still crashing, try setting the Target Android Version and Minimum Android Version explicitly, rather than using the Automatic - use target framework version setting, and see if that solves it. If not, the only other thing I can ask is to copy the output generated in the Application Output window in Xamarin Studio to a text file and post it here.

  • TimFTimF USMember

    Thanks! That seems to have helped.

    How come having Fast Assembly Deployment checked causes this problem?

  • TimFTimF USMember

    It seems this didn't fix the problem after all. I'm seeing it again, even with Fast Assembly Deployment unchecked.

  • TimFTimF USMember

    Has anybody else encountered this problem? It happens pretty much all the time now. Only options are to uninstall the application or do a rebuild every time, which is really slowing down my development.

  • I have the same problem, Fast assembly deployment did not help. I continuously uninstall package, rebuild/clean application until it updates... completely frustrating.

  • TimFTimF USMember

    @GreggJohns.8260 I have found a workaround, although it's not ideal: I've found that if you touch any file in the platform dependent solution it should build properly. For example, I'm doing a Xamarin.Forms project, and if the build system doesn't always notice changes in my PCL. But if I touch my Android project's MainActivity.cs, a proper build gets made.

    Hope that helps

  • GreggJohnsGreggJohns CAMember

    @TimF Really? I think I had the same issue when altering MainActivity.cs, but will try next time this occurs and post if the workaround holds for me.

  • TimFTimF USMember

    Another thing to check is to make sure the time on your development machine and device are in sync. I've had some problems with my Xamarin Android Player device with time zones, auto time update, etc.

  • GreggJohnsGreggJohns CAMember

    @TimF Just ran into the same problem as before, tried modifying MainActivity with no resolve. Times on development machine and device seem to be in sync.

  • Xamarin needs to fix this problem. I can not produce any build without having to rebuild each time. How am i supposed to test my Android apps if I have to rebuild each time and then deploy. Unacceptable.

  • GreggJohnsGreggJohns CAMember

    Any news on a fix for this problem? At one time it was suggested to modify main activity to resolve the issue. However, this workaround does not seem to be effective. I am still encountering this issue! Xamarin contacted me basically saying they had never heard of this issue, despite this thread having been established in July, they contacted me regarding sample projects which I cannot provide. Completely insane!

  • DonFitzsimmonsDonFitzsimmons USMember ✭✭

    I'm having the same problem with iOS. Every time I deploy to device, I have to clean the solution first. I am on the Alpha build though (6.0).

  • DominicMarierDominicMarier CAMember

    Same for us. Only on android. Every time I press Run, if i didn't touch a file, the app will never start, and visual studio will never stop. it's waiting on something, but I don't know what.
    There is no log in the %appdata%xamarin/logs/ or in the visual studio output folder (even with verbose).
    I'm trying to repro the problem with a new project, but it doesn't happen.

  • RobertEwen.5328RobertEwen.5328 USMember

    Same for us (Android). We have a PCL + Android...

    Please Xamarin: You really need to invest more time in answering requests in this Forum!!
    About 70-80% of all "results" i found for my researches for the many problems we have with xamarin are unanswered by xamarin - no reactions at all - you really need to invest more manpower in supporting your xamarin community!!!

  • AbelDJOUHRIAbelDJOUHRI USMember

    I have the same problem...
    I tried every advice in this topic, not of them works :(

    Does anybody has a solution ?

    I can't imagine that every xamarin forms developer works like that, it's really painful.
    We can't be sure that our last changes are deployed, it is really time consuming.

  • LinhNgo.3760LinhNgo.3760 USMember

    Had the same problem with iOS. Made changes to Xamarin.Forms PCL (with Grial UI.Toolkit), but no changes on the simulator. Had to delete the app from the simulator before I saw any changes. Very annoying.

  • JulianBoothJulianBooth GBMember

    I am having this problem now with Android and nothing seems to fix it using Xamarin Studio on OSX. I've been using Xamarin since 2012 and the experience recently seems to be getting worse not better. I'm at the position where going native is becoming so much more attractive. Any productivity I gain from using C# is lost with issues like this. This product should be mature enough that we are no longer having these sorts of issues. I don't mind the odd issue but this is consistent and I can't fix it.

  • 15mgm1515mgm15 USMember ✭✭✭

    I am having the same issues with Xamarin Studio 6, my teammates have Xamarin Studio 5 or using Visual Studio and they can build and debug w/o any problems, it seems that the configuration mapping are creating this types of problems, I can debug using Iphone Simulator but not with Android emulators or devices, using "Run with" option I can deploy to devices but I cannot debug, trying to change to alpha channel only make the things worse, here are some pics:

    Any ideas?

  • JoelChowdhuryJoelChowdhury USMember

    as I was trying to add some stuffs for my ToggleButton, I noticed that I could press on it, but it wouldn't do the stuffs I told it to do in code...

    with a little Google and experimenting, I made a final confirmation by changing
    button.Text = string.Format("{0} clicks!", count++); into
    button.Text = string.Format("{0} clicks hey!", count++);, but it still displayed the "1 clicks!" text, when I run it...

    I tried various methods, including deleting bin and obj, de-checking Fast Deployment and Shared Runtime, enabling armeabi and armeabi-v7a (they was already enabled), granting permissions but none of them worked...

    I tried running on both Nexus 4 and 10, but it seems like it only accept changes from the layout and completly ignore any changes (but the default) done in the various Activities...

    Xamarin, you really need to step up your games and actually check the forum, seeing for how long this have been alive

  • DenisGordinDenisGordin RUMember ✭✭

    I have same issue.
    Often it's happening with PCL projects (i working with MvvmCross) and, of course, it's working only on Xamarin Studio.

    Sometimes nothing can't help me, not clean, rebuild or delete app from simulator. Only closing and opening XS works for me.

  • HRO_JordyHRO_Jordy NLMember ✭✭
    edited July 2016

    Same issue here. Updated Xamarin and related stuff yesterday, and today my old code gets deployed everytime I run and debug to Xamarin player. I'm using Visual Studio 2015.

    Edit: a factory reset of the Xamarin Android Player Device seems to have fixed my issue. For now...

  • HRO_JordyHRO_Jordy NLMember ✭✭

    Nope, that was a temporary solution. After building and deploying, the old code is running again. :(

  • The solution from AlexRod works for me - thank you!

  • PubuduGayanPubuduGayan NZMember ✭✭✭
    edited August 2016

    No Way I had this headache from this afternoon … but @AlexRod solution was saved me. Just humble request as this is going to be mysterious problem lets give a like to the answers which solved this problem.

  • VineetSinglaVineetSingla USMember

    The solution from AlexRod works. I found that you don't need to erase Release/obj, Release/bin, Debug/bin, Debug/obj. Just uninstalling the app from device or emulator takes care of the problem.

  • MikeeSouthMikeeSouth USMember ✭✭

    I still have this problem with Android development from Visual Studio. What I've noticed is that if I change an xml or axml file and press "Deploy", then the app is removed from the app drawer and then readded (i.e. uninstalled + installed again). This always works. If I just change a code behind file, e.g. MainActivity.cs, the deployment is much faster but the app is NOT uninstalled/reinstalled and my changes are NOT applied. If I uninstall the app from the emulator and deploy again - then it works. If I change a xml or axml file and deploy - then it works.

    I've tried with and without the Tools => Options => Xamarin => "Preserve application data/cache on device between deploys".

    Any ideas on how to get this to work? It's fairly irritating since I often debug stuff that isn't wrong (it just isn't deployed correctly). Also - a full deploy is of course slower and thus more time consuming in the development process.

  • AirtonGomesdeLimaAirtonGomesdeLima USMember
    edited September 2016

    Just do a "clean solution" in Visual Studio.
    Then if you get the "System.IO.FileNotFoundException", remove the xamarin nuget package and install again.

  • AlexRod's solution (without cleaning up obj folders) works, saved my week. Thanks!
    [Really, really annoying. Bugs [[features]] like these make life "interesting", like hitting your finger with a hammer to forget you have a headache....] Anyway, again, thanks.

  • dengerelidengereli TRMember ✭✭

    I cleaned bin folders manually (for visual studio) and droid debug working...

  • I'm getting this all the time too, when I do notice it happens uninstalling the app first always fixes it.

  • DeanEllisDeanEllis USXamarin Team Xamurai

    For those of you having this problem can you try something for us.

    Go to Xamarin Studio: Help > Open Log Directory
    and attach the AndroidTools.<DATE>.log file. That should contain some of the information we need to diagnose this issue.

    Alternatively you try deploying from the command line.

    Make the changes in the app as normal then from the command line run

    msbuild project.csproj /t:Install /v:d > build.log

    (those of you on MacOS can use xbuild instead of msbuild).

    If you get the same problem, i.e the app is NOT updated with the changes. attach the build log so we can take a look at what is happening. If possible make a note of which file was changed.

    For background, when FastDev is enabled (which you should use when debugging) the app on the device will only be updated if resources have changed. If you only change C# code the assemblies will be moved to a special directory which in the installed app picks up.

  • DanysChalifourDanysChalifour USMember ✭✭

    Found out a solution
    Build=> Configuration Manager... => Active solution configuration=> set it to Release

  • GarbimGarbim BRMember

    Why would set this to Release solves the problem ?

  • vinnivinni INMember

    I had the same issue. Uninstalling the application from the emulator and re-built it. It worked!

  • FredrikSvenssonFredrikSvensson USMember
    edited February 1

    So I've been having this issue, or at least I thought this was the issue, for a long while. I'm running fast deployment and shared runtimes during development. I'm on Visual Studio 2015 with the current latest stable release of Xamarin.

    The symptom is that if I change a code file and redeploy/run the app without debugging, I will not see my latest change. If I redeploy/run once more, the changes will appear. This is repeatable every time.

    I've been looking at the build process trying to figure out if there is something wrong there. It turns out though that it has nothing to do with the build. The code is properly built and the result is deployed into the .../.__override__ path on my emulator. The problem is that the changes aren't picked up during the app restart on the emulator. If I kill the app through the task switcher and restart it, the changes will appear.

    As an addition to this post, this is how I solved my problem for now.
    In the project properties, under build events, I added a post-build event like this:
    adb shell am force-stop my.app.package.name

    This works if you have adb in your path and only one device connected. I suppose you "should" be able to pick up the path to adb through properties defined in the build, and perhaps even the device you are deploying to as well as your package name. But this will have to do for me right now.

  • JGoldbergerJGoldberger USXamarin Team, University Xamurai
    edited February 4

    @FredrikSvensson ,

    Thanks for posting your findings and that is interesting. I tried to reproduce the issue with both a Xam.Android and Xam.Forms PCL solution, but could not. Code changes were picked up whether in the Android platform app project or in the Forms PCL project, XAML or C# code.

    Could you provide some concrete steps to reproduce so I can try to replicate the issue and see what can be done to mitigate this issue?

    Also it would be helpful if you could provide the info requested by Dean Ellis above (https://forums.xamarin.com/discussion/comment/238926/#Comment_238926)

«1
Sign In or Register to comment.