-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uninstalled app is not redeployed #3727
Comments
So it looks like out Task which detects if the app has been uninstalled is not completing before the Also we should check to make sure the Shared Runtime etc is still installed. |
Hmm we already have a unit test for this https://github.com/xamarin/xamarin-android/blob/master/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs#L35 |
Context dotnet#3727 Somehow sometimes the code we have does NOT detect that the user uninstalled the app. As a result the `_Upload` target does not run. This commit just adds some additional checks to make sure we skip that target when we should, and run it when we need to.
Context: #3727 Sometimes the `_Upload` target code does NOT detect that the user uninstalled the app, which means the `_Upload` target does not run. We do not yet understand *why* this happens. Add some additional checks to the `InstallTests.ReInstallIfUserUninstalled()` unit test which assert that the target is skipped when it should be skipped, and executed when it should be executed. Hopefully this might help us detect if and when this problem happens on our CI build system when unit tests are executed.
Changes: xamarin/monodroid@663fa21...400af80 Reopens: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/994494 Reopens: #3727 The fix for Issue #3727 broke the build. Revert it.
A fix for this issue was merged via xamarin/monodroid@663fa21 and xamarin/monodroid@400af80 |
Release status update A new Preview version has now been published on Windows that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix. The fix is not yet available on macOS. I will update this item again when a Preview version with the fix is available on macOS. Fix included in Xamarin.Android 10.2.0.16. Fix included on Windows in Visual Studio 2019 version 16.5 Preview 1. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview. Fix not yet available on macOS. |
Release status update A new Preview version has now been published on macOS that includes the fix for this item. Fix included in Xamarin.Android 10.2.0.84. Fix included on macOS in Visual Studio 2019 for Mac version 8.5 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel. (Fix also included on Windows in Visual Studio 2019 version 16.5 Preview 1 and higher. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.) |
Release status update A new Release version has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix. Fix included in Xamarin.Android 10.2.0.100. Fix included on Windows in Visual Studio 2019 version 16.5. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/. (Fix also included on macOS in Visual Studio 2019 for Mac version 8.5 Preview 1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.) |
Release status update A new Release version has now been published on macOS that includes the fix for this item. Fix included in Xamarin.Android 10.2.0.100. Fix included on macOS in Visual Studio 2019 for Mac version 8.5. To get the new version that includes the fix, check for the latest updates on the Stable updater channel. (Fix also included on Windows in Visual Studio 2019 version 16.5 and higher. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.) |
I still have same bug. Visual Studio & Xamarin just frequently fails to deploy and fails to start debugging session with:
I have to use reliable workaround, which is: Forcing Visual Studio to create *.apk file on every debug build by adding AndroidBuildApplicationPackage element inside Debug property group of *.Android.csproj file: <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<AndroidBuildApplicationPackage>true</AndroidBuildApplicationPackage>
... Running DOS batch script ClearApp_Reinstall.bat, which deploys new debug *.apk manually to the Android phone or emulator: SET app=com.package.name
SET adb=%ProgramFiles(x86)%\Android\android-sdk\platform-tools\adb.exe
"%adb%" uninstall "%app%"
"%adb%" push "Mobile.Android\bin\Debug\%app%-Signed.apk" "/data/local/tmp"
"%adb%" shell chmod 750 "/data/local/tmp/*.apk"
"%adb%" shell pm install -t -r "/data/local/tmp/%app%-Signed.apk" Basically: Build, run the batch file and then start debugging. |
@EJocys if you are getting this on a regular basis could you install the You can then use that to get us the Basically we need the logs for the Under normal operations what should happen is you click Run in Visual Studio and it will detect if the app a) has been updated and needs to be installed or b) does not exist on the device and needs to be installed. The It would also be interesting to see the settings you have in your Debug configuration so we can make sure you are correctly setup for debugging. |
Issue starts with Visual Studio failing to build and deploy *.apk, which contains changed code. VS just just skips deployment process and starts old app for debugging. So, as a workaround I am uninstalling the app directly from the phone. This will trigger "Error: Device could not find component named:..." error when trying to debug. Visual Studio throws this error immediately, without any building or deploying. Build logging shows event below and trying to save anything saves nothing: Now there is interesting part. If I open Android project properties, go to "Android Options" and keep tab open (which makes Visual Studio not to loose focus from the Android Project in Solution Explorer) then sooner or later this line appears: Now, it is possible to save some logs. Also, selecting Android project and doing "Debug -> Start New Instance" results in Visual Studio deploying and starting new debug session successfully. So, opening "Android Options" will trigger some event, which will resolve the error which is the topic of this issue. I can rinse and repeat this with: a) Going to *.Mobile shared Xamarin project and changing one value in the code like "var x = 2;" then, Firs time it does some building and then just fails with the error: "Error: Device could not find component named:..." then just fails reliably and immediately with the same error unless I open "Android Options" of Android project (which is workaround 2). P.S. I have all up to date in Visual Studio 2019 via Visual Studio Installer. |
@EJocys changing C# code should not need to re-install the apk if you are using the fast deployment system which should be on by default. You should not need to keep uninstalling the apk each time. Can you share the debug configuration for your application? I suspect you have some settings turned off/on which are interfering with the way our fasted system works. As for the logs, you need to keep an eye out for entries which have |
@dellis1972: I would be glad to use fast deployment but it was just not working reliably. I would end up debugging old code, because Visual Studio would fail to deploy new code. I've started to use reliable alternatives exactly because Visual Studio auto-deployment options were not reliable. Visual Studio error suggests that it can't find component "com.package.name/md<MD5>.MainActivity" when all "com.package.name" app is missing. It would be more reasonable error if it said: Debug config with sensitive info removed. It can create *.apk if forced no problem. Deployment is the issue:
|
Steps to Reproduce
Expected Behavior
App is redeployed to device and debugging succeeds.
Actual Behavior
Note that retrying a second time succeeds.
Version Information
VS 2019 16.3.2
Log File
build.log
The text was updated successfully, but these errors were encountered: