Skip to content

Deploying app is unreliable for both Debug and Release builds #6652

Description

@gmck

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.)

Affected platform version

VS 2022 17.1.0 Prev 2.0

Description

The last few weeks I’ve only been doing Debug builds and I’ve found that VS 2022 17.1.0 Prev 2 is not very reliable when it comes to deploying to the device. There doesn’t appear to be a pattern, just every now and then you get a message that the Deploy failed. Usually, it is because I tried a one stepper Build/Deploy. The build goes fine and at the end of the build, it starts to deploy and immediately fails. A normal clean/rebuild/deploy all separate steps then fails again on the deploy. The only way I’ve found to fix it is to close VS and start again and then it works fine until the next time it decides to fail which may be some hours later after plenty of good deploys in between.

Today I was ready for a Release build for Google Play. I swapped to Release, Clean, rebuild, deploy and it failed to deploy. Again, I exited VS and the next time it then created the aab and all was good with the upload to Google Play.
I’m attaching that particular build log as it demonstrates something that I thought was fixed sometime back last year.

Task Parameter:ConsoleToMSBuild=True
Task Parameter:Command="C:\Program Files (x86)\Android\android-sdk\platform-tools\adb" -s 0B251JEC218062 uninstall -k "com.glmsoftware.OBDNowPro"
"C:\Program Files (x86)\Android\android-sdk\platform-tools\adb" -s 0B251JEC218062 uninstall -k "com.glmsoftware.OBDNowPro"
The -k option uninstalls the application while retaining the data/cache.
At the moment, there is no way to remove the remaining data.
You will have to reinstall the application with the same signature, and fully uninstall it.
If you truly wish to continue, execute 'adb shell cmd package uninstall -k'.
The command ""C:\Program Files (x86)\Android\android-sdk\platform-tools\adb" -s 0B251JEC218062 uninstall -k "com.glmsoftware.OBDNowPro"" exited with code 1.
The previous error was converted to a warning because the task was called with ContinueOnError=true.
Build continuing because "ContinueOnError" on the task "Exec" is set to "True".
Done executing task "Exec" -- FAILED.

The warning still has no effect on the deployment, but it would be nice to get rid of it.

Later on, I realised that I’d forgotten to change a resource string in a dialog, so I made the change while it still was in Release. Built and deployed successfully and when I went to check the change, the string was as it was before I made the change. The same thing as before, exited VS and restarted and the next deploy contained the changed string. I don’t think I’ve ever seen that type of failure before when I’ve made a change in strings.xml

Steps to Reproduce

AS above

Did you find any workaround?

As above

Relevant log output

Won't attach.

Activity

  1. added
    Area: App+Library BuildIssues when building Library projects or Application projects.
    needs-triageIssues that need to be assigned.
    on Jan 19, 2022
  2. gmck commented on Jan 19, 2022

    @gmck
    Author

    @dellis1972, @jonathanpeppers. I can't attach the file either way and it is way too big to paste. Will come up with a link later instead.

  3. gmck commented on Jan 19, 2022

    @gmck
    Author
  4. dellis1972 commented on Jan 19, 2022

    @dellis1972
    Contributor

    @gmck so is this log from the Release build which did not contain the changed file?

    It would also be useful to see the deployment error your are getting when in Debug mode if you have that log too.

    Regarding the The -k option uninstalls the application while retaining the data/cache. warning. Unfortunately that is not something we can deal with. That warning is raised by adb itself. We can try to dig into the code to see what makes adb raise that warning, but its possible we might not be able to do anything about it. My experience is it happens when installing apk's which are signed with different keys, or have some resource changes which trigger this code path.

  5. added
    need-infoIssues that need more information from the author.
    and removed
    needs-triageIssues that need to be assigned.
    on Jan 19, 2022
  6. dellis1972 commented on Jan 19, 2022

    @dellis1972
    Contributor

    Looking at the log I'm seeing this

    Skipping target "_CompileResources" because all output files are up-to-date with respect to the input files.
    

    Assuming this is a build when a resource file was changed that is a bit odd. It suggests that the file changed was not in the list of inputs for this target or the IDE hadn't saved it.

  7. gmck commented on Jan 19, 2022

    @gmck
    Author

    Re the release build. Well, I suppose if I'm installing a release build over a debug apk, then adb is correct because we are using different keys. Therefore I conclude that before deploying a release build as an aab, we should manually delete the previous debug apk from the device. I just thought that would have been automatic.

    I thought I remembered you and @jonathanpeppers discussing that on Discord some time ago and you said that check could probably be removed - actually, it might not have been you maybe someone else discussing with peppers.

    _Skipping target "CompileResources" because all output files are up-to-date with respect to the input files.

    Shouldn't the IDE save strings.xml if there has been a change as there was in this case? It certainly worked the next time I deployed - i.e. the altered string was then in the dialog.

    Re the debug builds, I'll try and remember to save the logs the next time it happens. I just get impatient at that point and restart the IDE and it is ok again the next time I deploy. That bug with the OK button took way too long to solve and the deploying problem wasn't helping with my patience. Will anyone check that example I uploaded to the forum or should I move it over to here?

    The deployment error is just that - failed to deploy.

    Why the problem with trying to attach logs? Can't remember that happening with the old issue templates.

  8. gmck commented on Jan 19, 2022

    @gmck
    Author

    @dellis1972
    I tried again with a Release build this morning. Prior to deploying I manually deleted the app from the device. Then I deployed and still got the same message re "The -k option uninstalls the application while retaining the data/cache etc.." I tried finding that string on Discord - but no luck there. Maybe if you ask @jonathanpeppers, he may remember the conversation about it. As usual, no harm done, the app was deployed and ran normally with the latest change I had made.

    I then swapped to a different device, deleted the app and tried to Deploy. I'm attaching the log of that one because that gave really weird stuff about - Missing APKs for [SCREEN_DENSITY] dimensions in the module 'base' for the provided device. Never seen that before.

    Seems to me that the build doesn't recognise that the device has changed, even though VS indicates it has.

    Cleaned rebuilt deployed and ran ok after that - also had the -k option message as above.

    ReleaseBuild20012022.txt

  9. gmck commented on Jan 19, 2022

    @gmck
    Author

    @dellis1972
    Just tried to deploy to another device. The app was not on the device, got the SCREEN_DENSITY stuff again. Shutdown and restarted VS and same thing again with the SCREEN_DENSITY warning.

    Cleaned and rebuilt and deployed all ok, but still with the -k option warning.

    Anything else you want me to try?

  10. dellis1972 commented on Feb 10, 2022

    @dellis1972
    Contributor

    @gmck

    Looking at the log you provided it seems like you are trying to debug while using aab files?
    Thats not a setup we recommend unless you are using Dynamic delivery. So it's possible there might be some issues in that area. It's also allow slower. The most optimal Debug experience is apk + Fast Deployment.

    That said, looking at the logs it does seem that we did fully build the _BuildApkEmbed target, which is what I would expect in this case since you switched devices.
    I'll try and replicate your settings in an app locally to see if I can replicate the issue you are seeing.

  11. 28 remaining items

  12. dellis1972 commented on Apr 8, 2022

    @dellis1972
    Contributor

    I just had confirmation that the fix for this issue is shipping is 17.2 Preview 3.

  13. dellis1972 commented on Apr 8, 2022

    @dellis1972
    Contributor
  14. mgierlasinski commented on Apr 22, 2022

    @mgierlasinski

    I can't believe such issues still happen and the only workaround since 3 months is to reopen solution. For me every change to Android xml requires reopening solution. Hot reload can have many meanings...

  15. mfranke-moba commented on Apr 22, 2022

    @mfranke-moba
    Contributor

    Had the same problem. What helped me was switching to Visual Studio 2022 LTSC.

  16. uholeschak commented on Apr 22, 2022

    @uholeschak

    Using good old VS2019 is an option ...

  17. highwingers commented on Apr 22, 2022

    @highwingers

    Using good old VS2019 is an option ...

    I am working on a .NET 6.0 project. its not an option for me. "Preview Release" did the trick for me.

  18. MagicAndre1981 commented on Apr 30, 2022

    @MagicAndre1981

    I just had confirmation that the fix for this issue is shipping is 17.2 Preview 3.

    17.2 P5 still has deployment issues.

  19. MagicAndre1981 commented on May 4, 2022

    @MagicAndre1981

    With 17.2 Preview 6 I now get errors about random files that are already in use and deploy is canceled...

  20. dellis1972 commented on May 4, 2022

    @dellis1972
    Contributor

    @tondat are you able to shed any light on these issues? What data does the IDE team need to investigate?

  21. MagicAndre1981 commented on May 4, 2022

    @MagicAndre1981

    ok, the user @dsaf gave me a hint that also works for me. Running VS2022 as admin does the trick for me. Now my errors about files that are in use are gone and deploy also works fine 🤷‍♂️

  22. dellis1972 commented on May 4, 2022

    @dellis1972
    Contributor

    Anyone with an issue can you do the following please

    Please run devenv /log to open the IDE. Repo the issue then get the ide logs from %localappdata%\Xamarin\Logs\17.0 and post them here.

  23. ghost closed this as completedon Jun 1, 2022
  24. MagicAndre1981 commented on Jun 3, 2022

    @MagicAndre1981

    for me the issue still happens in 17.3 P1.1 and this time running VS as admin doesn't fix it

  25. ghost locked as resolved and limited conversation to collaborators on Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.need-infoIssues that need more information from the author.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions