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



  • AleksandarLUKICAleksandarLUKIC Aleksandar LUKIC USMember

    I'm currently running on this problem.
    But for now, I didn't found a solution.

    What changed since it was working is that I was developping a Windows Phone version of my app and came back on the Android App to fix something.

    I don't have steps to reproduce but tell me if I can help Jon.

  • Slava87Slava87 Slava Shay UAMember

    I think I found out why this problem is happening. The reason is that in .Droid projects /bin and /obj folders remain busy by some processes even after deployment on the testing device is finished. And if one does a new build after short period of time either happens an error or and old version of build is used. If wait few minutes after the first build, then, during a new deployment everything works well and all functionalities are updated. I am just a very fresh beginner, so sorry if my comment is not relevant or not correct

  • JGoldbergerJGoldberger Jon Goldberger USXamarin Team, University Xamurai
    edited February 14


    Thanks for those observations. It might still help to get the info Dean Ellis asked for in this post on this thread.

  • baigzbaigz zahid baig PKMember

    I have the same issue nothing so far have resolved my issue. I have followed all of the above mentioned trick. Please help it started to frustrate me.

  • NateVargheseNateVarghese Nate Varghese USUniversity ✭✭
    edited February 16

    I have this too. Its so annoying. It's been happening for at least a month now when archiving in Release mode.

    Attached the log Dean Ellis asked for. I had to change the extension to .txt because these forums don't seem to accept .log files.

  • DeanEllisDeanEllis Dean Ellis USXamarin Team Xamurai

    Thanks for the data.

    If you look at the log there are allot of "SkipCopyFile" comments. If the file you modified has a SkipCopyFile next to it then it seems adb thinks that file did not change.

    The next step is to get the full diagnostic build output for the project. Along with the name of the assembly that was changed. That way I can take a good look at the logs. Alternatively you can do the whole thing from the command line

    msbuild /t:SignAndroidPackage /v:d > build.log
    msbuild /t:Install /v:d > install.log

    That will give us all the data we need. Note we do need to know which assembly/file was changed otherwise it makes it hard to see why things are not working.

  • JoeyZacherlJoeyZacherl Joseph Zacherl USMember ✭✭
    edited March 21

    So I have this issue every now and then. Usually nuking bin and obj directories solves it. Today, that's not the case. And to make things even more strange, it's building the latest code on Phone A but building old code to Phone B. Very strange.

    Here is my procedure.

    -Remove app from Phone A
    -Clean entire solution
    -Nuke /bin and /obj directores
    -Deploy to Phone A, phone a is running old code...

    -Remove app from Phone B
    -Clean entire solution
    -Nuke /bin and /obj directores
    -Deploy to Phone B, phone a is running the latest code fine

    Here are my Android Tools and IDE logs:


    I was able to resolve this by doing the following in terminal:
    cd /Users/myName/Library/Developer/Xamarin/android-sdk-macosx
    adb uninstall com.mycompany.myappname

    Looks like the app wasn't really removed from my device despite me doing an uninstall. And when deploying from Xamarin, it wasn't overwriting it.

  • JoeyZacherlJoeyZacherl Joseph Zacherl USMember ✭✭
    edited March 22

    I was able to resolve this by doing the following in terminal:

    cd /Users/myName/Library/Developer/Xamarin/android-sdk-macosx
    adb uninstall com.companyname.appname

    This fully removes the application from the device. My issue was that the app was not getting removed from the device despite me uninstalling. And Xamarin's deploy was not overwriting the old code.

  • AndyDentAndyDent Andy Dent AUMember ✭✭
    edited March 22

    The problem still occurs Xamarin Studio 6.2 build 1829.

    Uninstalling is not always an option - it's normally my first point of uninstalling on the device. In my case I'm debugging a problem that occurs for people doing updates :-(

    Changes to resources are being detected and propagated to the app but old code was still being invoked.

    As you can see from the screenshot below, the runtime type of the object being created is different - it's an older version of the class. The visible effects on the Android device indicate that is indeed what is happening. Somehow, an old version of MainActivity is being invoked and creating the old object.

    Things tried which made no difference:

    • restart the device
    • deleting bin and obj folders,
    • delete the Library/Developer/Caches/XamarinStudio-6.0
    • turn off Fast Assembly Deployment
    • turn off Use Shared Mono Runtime
    • enable Generate one package per selected ABI

    Note that, after I suspected code changes were not being propagated, I renamed the class, its file and even refactored the code so that the work is done in a different method. The debugger as shown in the screenshot thinks it is iterating the new code but is creating an instance of the old object.

    Android Tools log attached

  • AndyDentAndyDent Andy Dent AUMember ✭✭

    In my case I'm changing one tiny file that's linked into a small test program, so there are no separate DLLs being changed.

    Simple changes to the MainActivity.cs are being ignored - the code in the main fragment is not being propagated to the device.

    So I bit the bullet and uninstalled the application:

    • Built and ran the replacement version to ensure that when run as a clean install, the expected logic is invoked.
    • Uninstalled the replacement
    • Went back and built and ran the original app.
    • Stopped the original.
    • Used the Application manager on the device to do a Force Stop of the original
    • Rebuilt the replacement.

    Now, trying to run the replacement, get a very interesting error:

    Detecting existing process
    > am start -n "io.realm.testmigratefrom77_1droid/md50576fb6928abddee0e8c9d637bb1d306.MainActivity"
    > Starting: Intent { cmp=io.realm.testmigratefrom77_1droid/md50576fb6928abddee0e8c9d637bb1d306.MainActivity }
    Error type 3
    Error: Activity class {io.realm.testmigratefrom77_1droid/md50576fb6928abddee0e8c9d637bb1d306.MainActivity} does not exist.
  • AdriVermeulenAdriVermeulen Adri Vermeulen USMember

    The problem is solved for me after doing the steps in the link Stackoverflow answered by Yoruba.

  • BillDehortyBillDehorty Bill Dehorty USMember

    FWIW...I encountered a similar issue and a found a different work-around. (I am using VS2017 Community 15.2 Release 26430.6 + Xamarin + Xamarin.Android SDK In my case, I can never deploy my Android app more than once to the same Android Virtual Device in succession. The second and all subsequent attempts to the same virtual device will hang on the deployment. The emulator starts, and my app is installed in the emulated device, but the app won't start, and VS just hangs at the deployment step. To work around this, I created a second Android Virtual Device that is essentially identical to the first. As long as I keep toggling between the two virtual devices on every redeployment, the deployments succeed.

  • TigerLionCheetahTigerLionCheetah Abbas Zoeb CAMember ✭✭

    [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.


  • ahmeddriraahmeddrira ahmed drira USMember

    hey guys any news??

  • AlanJonesRiosAlanJonesRios Alan Jones Rios USMember

    So, here is my experience:

    I moved my project from one pc to other, then I got the same issue like everyone. It seems to me that VS have problems to deal with moved projects some times.
    All issues was been fixed when I erased bin and obj from android and ios projects.

Sign In or Register to comment.