Bug 26086 - [Android] Unable to install APK of previously installed app on device. Fails with "Deployment failed because of an internal error: Failure [INSTALL_FAILED_UID_CHANGED]"
Summary: [Android] Unable to install APK of previously installed app on device. Fails ...
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: Debugger ()
Version: 4.20.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2015-01-15 18:50 UTC by Kent Green [MSFT]
Modified: 2017-07-05 17:45 UTC (History)
9 users (show)

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

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Kent Green [MSFT] 2015-01-15 18:50:32 UTC
---Overview---
From this desk case:
https://xamarin.desk.com/agent/case/117393

Customer reports that sometimes after Xamarin goes into the busy mode and fails to launch they get an issue with installing further APK's of the application on the phone.

Deployment failed because of an internal error: Failure [INSTALL_FAILED_UID_CHANGED]
Xamarin.AndroidTools.AndroidDeploymentException: InternalError ---> Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_UID_CHANGED]
   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
   at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass2c.<InstallPackage>b__2b(Task`1t)
   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
   at Xamarin.AndroidTools.AndroidDeploySession.RunLogged(CancellationToken token)
   at Xamarin.AndroidTools.AndroidDeploySession.Start(CancellationToken token)


When this happens, from the research i've done, without having a rooted
device the only way to get around it is to factory reset the device since
the app no longer appears in the application manager.

---Build Information---
Microsoft Visual Studio Professional 2013
Version 12.0.30501.00 Update 2
Microsoft .NET Framework
Version 4.5.50938

Installed Version: Professional

LightSwitch for Visual Studio 2013 06177-179-0069956-02367
Microsoft LightSwitch for Visual Studio 2013

Microsoft Office Developer Tools for Visual Studio 2013 ENU
06177-179-0069956-02367
Microsoft Office Developer Tools for Visual Studio 2013 ENU

Team Explorer for Visual Studio 2013 06177-179-0069956-02367
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013 06177-179-0069956-02367
Microsoft Visual Basic 2013

Visual C# 2013 06177-179-0069956-02367
Microsoft Visual C# 2013

Visual C++ 2013 06177-179-0069956-02367
Microsoft Visual C++ 2013

Visual F# 2013 06177-179-0069956-02367
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker 06177-179-0069956-02367
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.

ASP.NET and Web Tools 2013.2.50425
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 Windows Azure Web Sites
Web publishing: Extensions for publishing ASP.NET web projects to hosting
providers, on-premises servers, or Windows 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.1.20409.0
For additional information, visit http://www.asp.net/

Common Azure Tools 1.1
Provides common services for use by Azure Mobile Services and Windows Azure
Tools.

JetBrains ReSharper 8.2 Full Edition build 8.2.0.2160 on
2014-03-20T23:53:08
JetBrains ReSharper 8.2 package for Microsoft Visual Studio. For more
information about ReSharper, visit http://www.jetbrains.com/resharper/.
Copyright © 2003–2015 JetBrains, Inc.

NCrunch
Continuous Testing Tool for .NET
Copyright © 2010-2014 Remco Software Ltd

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

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

SQL Server Data Tools 12.0.30919.1
Microsoft SQL Server Data Tools

Windows Azure Mobile Services Tools 1.1
Windows Azure Mobile Services 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.9.236.0 (d6a2cae)
Visual Studio extension to enable development for Xamarin.iOS and
Xamarin.Android.

Xamarin.Android 4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS 8.6.0.0 (eb24bdcf5cba2c12b673a07e0a8cce368b9563b3)
Visual Studio extension to enable development for Xamarin.iOS.

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

---Additional Info---
Requesting logs and sample from customer.
Comment 1 Kent Green [MSFT] 2015-01-15 18:55:20 UTC
Adding the following as a possibly related "See Also" link:

Bug 26025 - [Android] Visual Studio freezes while debugging
Comment 2 Kent Green [MSFT] 2015-01-15 18:58:59 UTC
(Forgot to include the ">" for readability, the exception in the description is as follows.)

>Deployment failed because of an internal error: Failure [INSTALL_FAILED_UID_CHANGED] 
>Xamarin.AndroidTools.AndroidDeploymentException: InternalError ---> Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_UID_CHANGED]
>   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
>   at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass2c.<InstallPackage>b__2b(Task`1t)
>   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
>   at System.Threading.Tasks.Task.Execute()
>--- End of inner exception stack trace ---
>   at Xamarin.AndroidTools.AndroidDeploySession.RunLogged(CancellationToken token)
>   at Xamarin.AndroidTools.AndroidDeploySession.Start(CancellationToken token)
Comment 3 Kent Green [MSFT] 2015-01-15 19:02:03 UTC
---Possible Workaround---
A quick note one of our other engineers pointed out is that if you run the following command from the Android console: 
"adb uninstall com.theircompany.packagename" , that should allow you to uninstall the app manually from the device without having to do a factory reset. 

To open the Android adb command prompt, you can either navigate in the command prompt to the folder with the Android platform tools, (by default "C:\Program Files (x86)\Android\android-sdk\platform-tools") or select the icon here: http://screencast.com/t/oY98wmhwe. (Highlighted in red.)
Comment 4 Gerry Hall 2015-01-15 19:50:38 UTC
The apk is showing as already uninstalled. On a rooted device there are parts left behind in /data/data but they never make it to the device. Since most test devices are not rooted then it's not possible to remove and the only way to fix it has been to do a factory reset so far.
Comment 7 Brad R 2015-01-16 07:49:21 UTC
I've had this happen before too.  In addition to the adb command (which works, but you have to put an 'x' before any numbers in your package name), you can also see the app via ->settings/application manager/ all.  It will be listed under the All section, but as the full package name(com.company.blahblahblah), not as the display name.  You can uninstall it that way if you don't have access to a computer with ADB on it.
Comment 8 Gerry Hall 2015-01-16 11:34:14 UTC
Unlike Brad's comments I think this is a different defect. It doesn't show up anywhere in the package manager, even under it's namespace.  It's only happening related to Bug 26086 when Visual Studio freezes and goes into busy mode, thus getting the ADB logs from the original occurrence that seems to trigger it is quite difficult as Visual Studio locks up solid and can only be reset by force closing it. I have never had it occur under normal conditions.
Comment 9 Gerry Hall 2015-01-16 11:35:20 UTC
Sorry, in the previous comment it should be Bug 26025
Comment 10 Kent Green [MSFT] 2015-01-16 11:44:31 UTC
Per comment 8 & comment 9, I noted that observation to our engineers working on Bug 26025 as well.
Comment 11 Ian Ceicys 2015-01-22 12:28:45 UTC
With the fixes included in build 274 for the January Service release the VS team believes this bug should be mitigated to some extent. 

We have  tried to reproduce this issue on build 274 but not able to reproduce. We followed the below steps to reproduce this issue:

1. Open VS and create Android template application.
2. Deploy the application on the device.
3. Again deploy the same application on the device.


Additionally the VS team believes this bug is from the underlying Monodroid implementation and for the   current 3.9.1 service release this will be moved out of scope. 

If additional information and Test Case steps can be captured this bug can be assessed and prioritized.
Comment 12 Ian Ceicys 2015-01-22 18:02:45 UTC
In reviewing this bug with John P we are updating this bug to Android and the following stackover flow post has several work arounds including:
"Restart your device, and clear your project." and
"change the package name of application, so that device recognizes it as different application and installation completes successfully. Might be helpful for those who don't have root access and also don't want to reset device."

http://stackoverflow.com/questions/16277422/android-install-failed-uid-changed
Comment 13 Chris Hardy [MSFT] 2017-07-05 17:45:39 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.