Bug 32443 - App authenticator uninstalled each time the app is deployed
Summary: App authenticator uninstalled each time the app is deployed
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Debugger ()
Version: 5.1
Hardware: PC Windows
: Normal enhancement
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2015-07-24 20:37 UTC by David Schwegler
Modified: 2017-12-26 16:58 UTC (History)
8 users (show)

Tags: papercut
Is this bug a regression?: ---
Last known good build:


Attachments
Sample authenticator project showing the issue (28.21 KB, application/x-zip-compressed)
2015-08-02 05:25 UTC, David Schwegler
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 32443 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description David Schwegler 2015-07-24 20:37:24 UTC
Disclaimer: Yes, I have "Preserve application data" enabled and I know that is working.

Our app has an Android Authenticator component (extends AbstractAccountAuthenticator) that we use for signing in. 

However, each time we deploy the app to the device, it appears Xamarin is actually uninstalling the app before it installs the new apk, rather than just re-installing (the equivalent of adb install -r). This is detrimental to apps with authenticators, because when the app using it is uninstalled, its accounts are removed from the system. 

We can see this is happening by looking at what the system's AccountManagerService is logging when the app is deployed:
07-24 17:17:29.643: W/AccountManagerService(758): deleting account user@foo.com because type com.foo no longer has a registered authenticator

This means we have to re-login to our app every time we deploy it to the device.

If we just build, then manually install the app (adb install -r foo.apk), the authenticator is retained as expected, so this appears to be a bug in how Xamarin is deploying the app.
Comment 1 David Schwegler 2015-08-02 05:25:00 UTC
Created attachment 12328 [details]
Sample authenticator project showing the issue

Attached a sample project demonstrating the problem. Notice that when you re-deploy the app, the authentication is gone.

Note: If you enable the Fast Deployment option and are deploying to an emulator, the authenticator is not uninstalled between runs. However, that option does not work in many environments (eg when deploying to Samsung devices, which include Knox), so that doesn't really fix the problem.
Comment 2 Kent Green [MSFT] 2015-08-11 17:44:23 UTC
Customer sent more detailed reproduction details in this desk case: https://kb.xamarin.com/agent/case/189772, based on the sample provided in the attachment for comment 1.

# Steps to Reproduce
1) Deploy from visual studio, debug mode
2) Click sign in
3) Enter random information in the authenticator.
4) Click done. See your info be displayed in the app.
5) Swipe away and restart the app. Notice that the info is still there. Go to system settings -> Accounts -> AuthenticatorUninstallOnDeploy and you will see your account
6) Re-deploy the app. Notice that the logcat says the authenticator was removed. Notice that the account is not displayed in the app. Go to system settings -> Accounts -> AuthenticatorUninstallOnDeploy and you will see the account has been removed as well.


# Partial Workarounds
Instead of step 6: If instead of re-deploying from visual studio, you simply navigate to your bin directory and re-install the app through adb (adb install -r AuthenticatorUninstallOnDeploy.AuthenticatorUninstallOnDeploy-Signed.apk), it will not be removed, so this is something peculiar to Xamarin’s reinstall process.

Enabling “Fast Deployment” does not cause the uninstall, but that option is kind of a hack, and doesn’t work in all our environments.


# Observations
I was able to reproduce the customer's issue based on the steps provided in the sample from comment 1; though I haven't confirmed the partial workarounds they described.

Because of this I'm marking this report as "CONFIRMED"

Screencast: http://screencast.com/t/YDXkSyFR



# Build Information
Microsoft Visual Studio Professional 2013
Version 12.0.40629.00 Update 5
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

LightSwitch for Visual Studio 2013   06177-004-0444002-02484
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06177-004-0444002-02484
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0444002-02484
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0444002-02484
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0444002-02484
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0444002-02484
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0444002-02484
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0444002-02484
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.5.60612.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Web Apps
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.30612.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.4
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

NuGet Package Manager   2.8.60610.756
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.41012.0
Microsoft SQL Server Data Tools

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.11.666.0 (ebae43a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.4.16 (5f55a9ef61c11b6ce0890bc91e4c71b1b92be214)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS   8.10.2.0 (67b390d0d1bd741582cf7b7fd3ffea08583a3f83)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 3 Mohit Kheterpal 2015-08-18 10:08:03 UTC
Thanks Kent,

I am also able to reproduce this issue with steps mentioned in comment 2.

adblogcat : https://gist.github.com/Mohit-Kheterpal/b85b6a2f21b7aa6dffb5
Comment 4 Mohit Kheterpal 2015-08-18 10:08:41 UTC
An update to the above comment, I am getting this issue with XVS 3.11.836
Comment 5 Jonathan Pryor 2015-12-17 21:05:39 UTC
The problem is that while we have support to use `adb uninstall -k`, which will keep the data and cache directories, we currently never use `adb install -r`.
Comment 6 David Schwegler 2015-12-21 23:08:19 UTC
Jon, can you clarify why you don't use adb install -r? Xamarin is the only IDE that doesn't. I can't think of any functional difference when not using fast dev (and even then, I assume you're already replacing the shared assemblies).
Comment 7 dpedrinha 2017-08-09 01:50:19 UTC
Same thing happens with GoogleApiClient. Need to login every time.
Comment 8 Avi Sadde 2017-12-26 16:52:22 UTC
Have exactly the same problem as David Schwegler:
- "Preserve application data" - CHECKED
- Using Android Authenticator component (extends AbstractAccountAuthenticator).
- Need to re-login to the app after EVERY deploy to the device.

I understand that the issue 'adb install -r' is unreliable on some cases. But at least give it as an option...
I belive it's the same as issue described in Bug 27266
Comment 9 Avi Sadde 2017-12-26 16:58:18 UTC
Have exactly the same problem:
- "Preserve application data" - CHECKED
- Using Android Authenticator component (extends AbstractAccountAuthenticator).
- Need to re-login to the app after EVERY deploy to the device.

I understand that the issue 'adb install -r' is unreliable on some cases. But at least give it as an option...
I believe it's the same as issue described in Bug 32443