Bug 60236 - Cannot deploy to Android Oreo (Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install Mono.Android.DebugRuntime without first uninstalling.])
Summary: Cannot deploy to Android Oreo (Failure [INSTALL_FAILED_ALREADY_EXISTS: Attemp...
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 8.0 (15.4)
Hardware: PC Windows
: --- normal
Target Milestone: 15.6
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-10-17 15:54 UTC by Peter Holthe Hansen
Modified: 2018-03-21 09:35 UTC (History)
20 users (show)

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


Attachments
Xamarin diagnostics log (60.88 KB, text/plain)
2017-10-17 15:54 UTC, Peter Holthe Hansen
Details
xamarin diagnostics output (43.46 KB, text/plain)
2017-11-20 12:40 UTC, Mike Mekkils
Details
Mono.AndroidTools.dll (d15-5 stable) (225.00 KB, application/x-ms-dos-executable)
2018-01-11 13:55 UTC, dean.ellis
Details
Detailed log - failing deployment after update of Mono.AndroidTools.dll (130.89 KB, text/plain)
2018-01-16 09:57 UTC, Milan
Details
Xamarin.Android (225.17 KB, application/x-msdownload)
2018-03-20 14:59 UTC, Simba Mupfunya
Details
Mono.AndroidTools (209.66 KB, application/x-msdownload)
2018-03-20 15:38 UTC, Simba Mupfunya
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 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 FIXED

Description Peter Holthe Hansen 2017-10-17 15:54:09 UTC
Created attachment 25336 [details]
Xamarin diagnostics log

I have just updated to Visual Studio 2017 15.4 with Xamarin 8.0.0.33. I have also updated the Android SDK, platform-tools and build-tools to 26.x

Now I cannot deploy my app to my Android O device from Visual Studio.

Setup:
Microsoft Visual Studio Professional 2017 
Version 15.4.0
VisualStudio.15.Release/15.4.0+27004.2002
Microsoft .NET Framework
Version 4.7.02053

Installed Version: Professional

Xamarin   4.7.10.22 (fe36bec)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   8.0.0.33 (HEAD/7a6a056e8)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.2.0.8 (9a9f054)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 1 Jon Douglas [MSFT] 2017-10-17 16:51:48 UTC
Hi Peter,

Have you tried to remove the Mono.Android.DebugRuntime from your device's application list as per the error message? Please go to your Settings -> Applications and remove the Mono.Android.DebugRuntime and any other Mono application such as API support so it can redownload.
Comment 2 Peter Holthe Hansen 2017-10-17 16:59:04 UTC
Hi Jon,

I have successfully removed Mono.Android.DebugRuntime along with the debug runtimes for API 21, 23 and 25 (those were the only ones installed). I did this via ADB and verified that they were not listed by pm list packages afterwards. The problem persists.
Comment 3 Peter Holthe Hansen 2017-10-18 10:57:33 UTC
I can successfully deploy when disabling "Use Shared Runtime" in Android Options in my project. 

It may be worth noting, that I am missing %localappdata%\Xamarin.Android\Cache\Mono.Android.Platform.ApiLevel_26.apk (at least, this is where Mono.Android.Platform.ApiLevel_24.apk is located), and I can see it in the Xamarin Diagnostics output.

- Peter
Comment 4 Peter Holthe Hansen 2017-10-18 11:12:25 UTC
Further, I have to uninstall the app (I am doing this via ADB) between each deployment.

- Peter
Comment 5 Eric Liu 2017-10-18 20:53:19 UTC
It's not just with Oreo. I have the same problem targeting 7.1. + For me monosharedruntime and apisupport not getting installed, everything is bundled into the generated APK (debug). 

Same xamarin extension 4.7.10.22 (commit fe36bec)

Whatever settings I choose, I'm getting "INSTALL_FAILED_ALREADY_EXISTS".
Comment 6 Eric Liu 2017-10-19 18:11:46 UTC
I completely deleted Visual Studio (caches, dotnet) and deleted all Xamarin related remains (appdata/local/xamarin etc...) Reinstalled vs+xamarin from scratch, and now it's working with the same target and same avd using 4.7.10.22 tool. (Reinstalling only VS did not helped at all)
Comment 7 Eric Liu 2017-10-19 18:13:30 UTC
* before you would delete "%appdata%/local/xamarin" folders, make sure you make backup or just save your android/ios keystores/keys
Comment 8 Jon Douglas [MSFT] 2017-10-24 16:44:20 UTC
Does anyone CC'd on this bug report have any way to reproduce this that I can look into? This bug sounds like an issue with regards to the shared runtime and API support being installed on your device. I'm curious if factory resetting your device may help this area? It may also be worth trying to use an Android Oreo emulator to see if you can reproduce this behavior.

My second guess would be a device cache in your project that can be cleared by removing the bin/obj folders and rebuilding your project.

Please let me know if this is still an issue and if these suggestions do not fix the problem.

Thank you!
Comment 9 Mike Mekkils 2017-11-20 10:57:33 UTC
I´m having the same issue.

I have an OnePlus 3t I use for debugging.
Out of curiosity I installed the Beta of Android O and then had the same issues.
I first thought the reason for this was the beta version of Oxygen OS so I downgraded back to Android N and it worked again without a problem.

Yesterday the official Android O update has been released for the device. After installing that one the issue was back.

Since I always do a factory reset of the device when installing major updates, this didn´t help here.

Clearing cache/bin/obj folders of the project didn´t help either.

Deactivating Shared Runtime works, but I have to delete my app before every deployment.

By looking at the xamarin diagnostics I can reproduce this manually with the following commands when the apk is already installed.

adb push "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Mono.Android.DebugRuntime-debug.apk" "/data/local/tmp/"

adb shell

pm install "/data/local/tmp/Mono.Android.DebugRuntime-debug.apk"

This results with:
Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install Mono.Android.DebugRuntime without first uninstalling.]

But when instead using the -r command:

pm install -r "/data/local/tmp/Mono.Android.DebugRuntime-debug.apk"

It gives a success.

So it seems that xamarin doesn´t recognize that the app is already installed and doesn´t add the -r parameter.

So I´ve checked the command for listing the packages which is used by xamarin.

pm list packages -f

In between all the packages I found this line.

package:/data/app/Mono.Android.DebugRuntime-5LENPaCGucxJsojTQ8wZ4w==/base.apk=Mono.Android.DebugRuntime

The interesting part here is this "5LENPaCGucxJsojTQ8wZ4w==".
Because no other app in the list has that in the apks filename.

So I checked for my own app it has that too.
I think this is the problem, because that cryptic string changes everytime the apk is installed although the apk itself didn´t change.

But I could be wrong in this regard since I don´t know how xamarin checks the list given by the command.

I´d need to check that behaviour on another device. But currently don´t have one. Maybe with an emulator but that has to wait for now.
Comment 10 dean.ellis 2017-11-20 12:00:18 UTC
Mike

Thanks for the info. There must be something wrong with the command we use to query if the runtime is present already. Either the format of the results have changed or the command is not working anymore. What is supposed to happen is it would be automatically uninstalled. 

Do you have the diagnostic output from your deployment?
Comment 11 Mike Mekkils 2017-11-20 12:40:52 UTC
Created attachment 25763 [details]
xamarin diagnostics output

The line with the Mono Shared Runtime apk is:

package:/data/app/Mono.Android.DebugRuntime-DpNyVwjXFQ2bshS3q4m0Qw==/base.apk=Mono.Android.DebugRuntime
Comment 12 Malte Goetz 2017-11-20 14:28:59 UTC
I can confirm the issue. Tested with a OnePlus 3 with Oreo. Deactivating "Shared Runtime", "Clean & Rebuild" + uninstalling the app before deployment fixed it for now. But a real fix would be good.
Comment 13 Simba Mupfunya 2017-11-24 13:04:14 UTC
Same issue here, we need fix please for debugging purposes
Comment 14 Pranoy Agrawal 2017-11-25 08:54:53 UTC
Same issue here as well in One Plus 3 with Oreo
Comment 15 ijovanoski 2017-11-26 12:15:59 UTC
Same issue on One Plus 5 with Oreo.
Comment 16 dean.ellis 2017-11-27 10:03:32 UTC
Looks like `GetPackages` is failing

[D:RunShellCommand]:      7dde889e cat /data/system/packages.xml
-- Start GetPackages - 11/20/2017 13:28:43 (14.0075ms) --
[INPUT] cat /data/system/packages.xml
[OUTPUT]
/system/bin/sh: cat: /data/system/packages.xml: Permission denied
-- End GetPackages --
[D:RunShellCommand]:      7dde889e cat /dbdata/system/packages.xml
-- Start GetPackages - 11/20/2017 13:28:43 (10.0084ms) --
[INPUT] cat /dbdata/system/packages.xml
[OUTPUT]
/system/bin/sh: cat: /dbdata/system/packages.xml: No such file or directory
-- End GetPackages --

So we are not getting the exact package name of the debug runtime. So it can't uninstall it.
Comment 17 dean.ellis 2017-11-27 10:39:10 UTC
For those interested we do a `broadcast` to retrieve the version numbers of the apps installed.

am broadcast -a "mono.android.intent.action.PACKAGE_VERSIONS" -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_26,<your app>" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions"

This should return data like the following.

Broadcasting: Intent { act=mono.android.intent.action.PACKAGE_VERSIONS cmp=Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions (has extras) }
Broadcast completed: result=0
, data="Mono.Android.DebugRuntime=1508512549,,"

The version returned from the packages is then compared with those on the PC. if they are different we do a re-install. For some reason it seems to believe it needs to re-install the apk.
Comment 18 dean.ellis 2017-11-27 10:40:39 UTC
Mike

Just out of curiosity, what versions of Visual Studio do you have installed? Is it just VS 2017 Pro or do you have others? 

I'm just wondering if the system is picking up a Mono.Android.DebugRuntime-debug.apk from another installation which has an older version..
Comment 19 Malte Goetz 2017-11-27 10:45:46 UTC
@Dean I can reproduce it with VS 2017 Enterprise (15.4.2) as well.
Comment 20 dean.ellis 2017-11-27 10:53:22 UTC
@Malte

do you only have VS 2017 Enterprise installed? Or do you have other versions with and older Xamarin.Android installed too?
Comment 21 Mike Mekkils 2017-11-27 10:58:39 UTC
@Dean
I have only Visual Studio 2017 Professional Version 15.4.4 installed.

By the way. Is this currently just a OnePlus problem?
I wanted to try an emulator but the Android Oreo Emulators currently aren´t working.
One isn´t starting (Black screen) and the other one with Google Play integrated can´t get an adb connection.

Sadly the official LineageOS for the OnePlus 3t is still only based on Nougat.
Comment 22 Malte Goetz 2017-11-27 11:02:48 UTC
@Dean I only have VS Enterprise installed and no other versions of Xamarin.Android as far as I know. Is there an option to check if there are old versions of Xamarin.Android installed? If so I would double check that.
Comment 23 dean.ellis 2017-11-27 11:09:44 UTC
@Mike

I don't get the issue with my Pixel 2 on Oreo so far. So it might be a One Plus problem. Looking at the output you get from the broadcast that seems correct.
Comment 24 dean.ellis 2017-11-27 11:12:47 UTC
Xamarin.Android could be installed in various `c:\Program Files (x86)` Directories.

The main ones will be

C:\Program Files (x86)\Microsoft Visual Studio\2017\<version>\MSBuild\Xamarin
C:\Program Files (x86)\MSBuild\Xamarin

Each version of VS 2017 will have its own copy. But the IDE should be informing the build/install system of where that it. Looking at Mike's log output that does appear to be the case. I was just wonder if an older version might be getting picked up. It would be good to discount that if possible.
Comment 25 Simba Mupfunya 2017-11-27 11:49:45 UTC
So Dean, i dont quite get it, what does this mean, does it mean that oneplus has the problem as it seems we are all using onleplus or the location for the Xamarin.android at build time is incorrect? If the later how do you change this so that it picks up the correct version. Im using VS2017 prof and onleplus 3.. 

Please note that this problem only started after updrading to Oreo
Comment 26 dean.ellis 2017-11-27 12:12:16 UTC
@Simba

It sounds like a oneplus problem. I have asked our QA team to see if we have a device to confirm the problem. At that point we might be able to find a work around. 

The questions regarding Xamarin.Android versions were to try and make sure that there wasn't another version of Xamarin.Android causing the problem. It does sound like this is not the problem at all. 

I have confirmed that things are behaving as expected using 15.4 and Oreo on a Google Pixel 2. Which is why I am beginning to suspect it is related to this device. 

This is not the first time we have had problems with specific devices. It usually down to the manufacturer changing the way the Android OS works slightly. This sometimes has unexpected side effects.
Comment 27 Simba Mupfunya 2017-11-27 12:18:11 UTC
@Dean

Thanks for the clarity.
Ill keep an eye on this ticket if anything comes up.
Comment 28 robins 2017-11-28 04:20:01 UTC
Same problem  

I have a OnePlus 3 phone that just got the Android Oreo update. Same problem as described here.  

Updated Visual Studio (for PC) to 15.4.5 version 4.7.02556
and problem persists.
Removed shared runtime, and problem persists.

Workaround to stopped using shared runtime caused this error:

Parameter name: Type is not derived from a java type.

Described here - apparently the fix is the turn back on your shared runtime...
https://forums.xamarin.com/discussion/58078/type-is-not-derived-from-a-java-type-startactivity 

So this phone will get a rest from development for a while, I guess...

Wondering if it has anything to do with OnePlus not supporting Project Trebel?? 
https://www.theverge.com/circuitbreaker/2017/11/22/16690022/oneplus-5t-android-oreo-project-treble 

Thanks for looking into it... I will be listening as well, for updates.
Comment 29 robins 2017-11-28 15:06:20 UTC
Update - I made a release build, supporting Oreo, and then downloaded and tried to run on the OnePlus 3 running Oreo and it installs fine, gets through the OS splash screen, but when it gets to the first XF-based screen, it crashes. So, I guess it is one thing when you can't run a development build, but quite another when users can't run your release...   ;-( I will see if I can extract some device logs...
Comment 30 Simba Mupfunya 2017-11-28 15:24:01 UTC
@Robins, its sounds as though you have an issue which might not be related to the issue we are experiencing with oneplus3 development "Shared Runtime" builds. I have a sideloaded app that works fine on "Release" and deployed to Oneplus 3 Oreo using XF2.5+. Suggest using "https://appcenter.ms/apps", they have a great crash analysis SDK that you can monitor your published apps, its free too for analysis
Comment 31 robins 2017-11-28 15:39:24 UTC
I agree, but I think I have the same build error described here, along with an added problem related to the java type. But my releases work on all other versions of droid I have tried so far (a Samsung running KitKat 19 and a OnePlusOne running Marshmallow 23 work just fine). 

I have Mobile Center/App Center Analytics and Crash Reporting wired up and working, but the crash apparently occurs before mobile center starts up because I am not registering any start up analytics nor a crash. 

The app has geofencing and Azure AD Authentication, so it is possible that there is a conflict somewhere with those libraries. I will keep digging... Thanks.
Comment 32 Edwin Otten 2017-11-28 15:42:22 UTC
Can confirm that the workaround in comment 12 works.

I'm developing on an OnePlus 3T. Had no problems before I updated from 7.1.1 to Oreo. Let me know if QA needs more information.
Comment 33 Milan 2017-11-28 20:31:07 UTC
The same problem here and I can confirm that the workaround in comment 12 works.

Device: OnePlus 3T. 

No problems before I updated from 7.1.1 to Oreo. 

Please let me know if you need some logs or anything.
Comment 34 Nuno Mendes 2017-11-30 15:57:55 UTC
Same problem here. OnePlus 3T.
The workaround mentioned in comment 12 works but it's really annoying...
Comment 35 dean.ellis 2017-12-07 10:26:58 UTC
Fixed in androidtools/master/ae7283b

Turns out the weird hash was breaking our output Parser. As a result the package Name was being picked up as `/base.apk` rather than `Mono.Android.DebugRuntime`. Which is why fails to a) remove the runtime and b) detect that its already installed.
Comment 36 Simba Mupfunya 2017-12-07 10:41:57 UTC
@Dean, This is good, happy problem was located and solved BUT what does it mean for us all, is there somewhere we can change or do we have to wait for a
xamarin patch or am i just daft
Comment 37 dean.ellis 2017-12-07 11:14:32 UTC
This patch will make it into the next release 15.6. We are going to see if we can include this in a service release for 15.5 though. Allot of that depends on the risk in updating `androidtools` across all of our products (it is used by Xamarin.Android, VSForMac, VS, the Designer and may others). 

That said I might be able to attach to this bug and custom build of the problem assembly which contains the fix. I have done this before. You would have to manually copy the assembly to the right place.

I'm not 100% how a custom dll will effect upgrading in the future though. It might be a hash check fails and a diff does not get applied or worse an upgrade fails.
Comment 38 Simba Mupfunya 2017-12-07 11:29:39 UTC
@Dean, Thanks for the detailed clarity it will for sure help others. I guess on a personal level i will wait for 15.6 update, its not a deal braker so its all good. CASE CLOSED
Comment 39 Nuno Mendes 2017-12-07 14:45:27 UTC
I would like to try the approach of manually copying the assembly to the right place, if that's ok?
Comment 40 Milan 2017-12-07 23:20:55 UTC
@Dean, thank you very much for the update. It's not a showstopper (but it is very annoying to always have to manually uninstall app before each Debug session). I can wait for 15.6., but it would be lovely to have it in 15.5. - I guess if it's only output parser change the risk is not very high.
Comment 41 Morten Nielsen 2017-12-13 21:15:33 UTC
@Dean I'm hitting something very much similar, (errors are slightly different but affects the same OS and the workaround to disable the shared runtime is the same).
I'd love to confirm this is the issue and it'll be fixed as it's affecting a lot of our customers who uses our components. So let me know where to get the DLL and I'll give it a run.
Comment 42 dean.ellis 2018-01-02 13:35:54 UTC
Sorry I have been on Annual leave for the last few weeks. I will try to get the custom dll containing the fix uploaded somewhere this week for those that want it.
Comment 43 dean.ellis 2018-01-11 13:55:24 UTC
Created attachment 26081 [details]
Mono.AndroidTools.dll (d15-5 stable)

This is the patched version for d15-5.
Note you might need to replace all instances of this.
Comment 44 Vantage 2018-01-11 14:27:07 UTC
Where we need to replace it?
Comment 45 dean.ellis 2018-01-11 14:39:36 UTC
C:\Program Files (x86)\MSBuild\Xamarin\Android

or 

C:\Program Files (x86)\Microsoft Visual Studio\2017\<edition>\MSBuild\Xamarin\Android
Comment 46 Simba Mupfunya 2018-01-11 14:50:18 UTC
@Dean, Isnt this published in 15.6 preview release already as well as the stable release soon to arrive?

Happy new year to all!!
Comment 47 Vantage 2018-01-11 14:52:46 UTC
Thanks for that. Should I delete pdb files?
Comment 48 dean.ellis 2018-01-11 15:02:20 UTC
It should be in 15.6 Preview releases. But not everyone wants to update. 
You don't need to worry about the pdb files.
Comment 49 Vantage 2018-01-12 11:12:11 UTC
Hi Dean, I have replaced the files at three locations but after that if I try to start the project it gives error.

C:\Program Files (x86)\Xamarin\Workbooks\Client
And
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Xamarin.VisualStudio
And
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android
Comment 50 dean.ellis 2018-01-12 11:14:46 UTC
Vantage

The same error or a different one? I might be I am missing a dependency, or the it might be a signing issue perhaps.
Comment 51 Vantage 2018-01-12 11:19:45 UTC
Different error. The project doesn't loads at all and popup says to see the ActivityLog.xml

C:\Users\<Users>\AppData\Roaming\Microsoft\VisualStudio\15.0_c40ec978
Comment 52 Vantage 2018-01-12 11:22:55 UTC
LegacySitePackage failed for package [XamarinShellPackage]Source: &apos;mscorlib&apos; Description: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.&#x000D;&#x000A;System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.&#x000D;&#x000A;   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)&#x000D;&#x000A;   at System.Reflection.RuntimeModule.GetTypes()&#x000D;&#x000A;   at System.Reflection.Assembly.GetTypes()&#x000D;&#x000A;   at Clide.CommonComposition.ComponentCatalog.&lt;.ctor&gt;b__0(Assembly a) in c:\projects\clide\src\Clide\External\CommonComposition.Mef\ComponentCatalog.cs:line 34&#x000D;&#x000A;   at System.Linq.Enumerable.&lt;SelectManyIterator&gt;d__17`2.MoveNext()&#x000D;&#x000A;   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.TypeCatalog.InitializeTypeCatalog(IEnumerable`1 types)&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.TypeCatalog..ctor(IEnumerable`1 types)&#x000D;&#x000A;   at Clide.CommonComposition.ComponentCatalog..ctor(IEnumerable`1 types) in c:\projects\clide\src\Clide\External\CommonComposition.Mef\ComponentCatalog.cs:line 51&#x000D;&#x000A;   at Clide.CommonComposition.ComponentCatalog..ctor(Assembly[] assemblies) in c:\projects\clide\src\Clide\External\CommonComposition.Mef\ComponentCatalog.cs:line 33&#x000D;&#x000A;   at Clide.DevEnvFactory.InitializeContainer(IServiceProvider services) in c:\projects\clide\src\Clide\DevEnvFactory.cs:line 118&#x000D;&#x000A;   at Clide.DevEnvFactory.&lt;Get&gt;b__0(IServiceProvider s) in c:\projects\clide\src\Clide\DevEnvFactory.cs:line 43&#x000D;&#x000A;   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)&#x000D;&#x000A;   at Clide.DevEnvFactory.Get(IServiceProvider services) in c:\projects\clide\src\Clide\DevEnvFactory.cs:line 42&#x000D;&#x000A;   at Clide.DevEnv.Get(IServiceProvider serviceProvider) in c:\projects\clide\src\Clide\DevEnv.cs:line 46&#x000D;&#x000A;   at Clide.Host.Initialize(IServiceProvider hostingPackage, Boolean registerCommands, Boolean registerCommandFilters, Boolean registerCommandInterceptors, Boolean registerOptionPages) in c:\projects\clide\src\Clide\Host.cs:line 91&#x000D;&#x000A;   at Xamarin.VisualStudio.TastyPackage.Initialize() in C:\d\lanes\4699\1be4f0c9\source\xamarinvs\src\Core\VisualStudio\FlavorProject\TastyPackage.cs:line 162&#x000D;&#x000A;   at Xamarin.VisualStudio.Shell.XamarinShellPackage.Initialize() in C:\d\lanes\4699\1be4f0c9\source\xamarinvs\src\Core\VisualStudio.Shell\XamarinShellPackage.cs:line 71&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)
Comment 53 dean.ellis 2018-01-12 11:45:25 UTC
ok that looks like the assembly is missing something or is incorrect :(. I'll have to rebuild it and test it again locally. Did you manage to backup the old assembly?
Comment 54 Vantage 2018-01-12 11:49:33 UTC
Yes, I had kept the old assembly and replaced the file with the new one and project started loading again.
Comment 55 Simba Mupfunya 2018-01-12 12:44:31 UTC
@Vantage after restoring the old assmeblies try replacing only the VS2017 on:
 
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android

and not all three, this works for me, as i had noticed all three having different sizes
Comment 56 Mike Mekkils 2018-01-12 14:05:28 UTC
The dll seems not to be working for me.

I replaced all instances of the File I could find(Made backups before of course)

In the following folders:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android
C:\Program Files (x86)\Xamarin\Workbooks\Client
C:\Program Files (x86)\Xamarin\AndroidSDKManager

I did NOT replace in the following folder, because the Extension was crashing when starting and the project wouldn´t load.
Probably the same error as Vantage had.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Xamarin.VisualStudio

But I still have the same error when deploying.

Well I´ll wait for 15.6 then.
Comment 57 Vantage 2018-01-12 14:48:39 UTC
@Dean @Simba
It's working for me as well. Thanks for your support. Just need to replace file IN FOLDER 
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android
Comment 58 dean.ellis 2018-01-12 14:52:53 UTC
cool. So ignore the comment to replace all instances. just replace the file in

C:\Program Files (x86)\Microsoft Visual Studio\2017\<edition>\MSBuild\Xamarin\Android

or if you are using VS2015

C:\Program Files (x86)\\MSBuild\Xamarin\Android
Comment 59 Vantage 2018-01-15 12:19:17 UTC
@Dean
There are still some issues with the dll. If I do not change the code it deploys the app but if I change the code, the previous issue still exists. Please help.
Comment 60 dean.ellis 2018-01-15 12:25:10 UTC
Vantage

Can you provide diagnostic output? Are you able to try the d15-6 Preview to see if that still has the issue.
Comment 61 Milan 2018-01-16 07:55:33 UTC
@Dean,

the same here - replacing just dll is not enough. However, I tried VS 2017 15.6 Preview 2 and I can confirm that the problem is resolved.
Comment 62 Milan 2018-01-16 09:57:37 UTC
Created attachment 26089 [details]
Detailed log - failing deployment after update of Mono.AndroidTools.dll
Comment 63 Milan 2018-01-16 10:01:35 UTC
@Dean, I've uploaded diagnostic log - this is VS 2017 - 15.5.3 with updated Mono.AndroidTools.dll. 

As mentioned above 15.6. Preview works fine.
Comment 64 Vantage 2018-01-31 12:47:37 UTC
Preview is also working properly. I had to uninstall the app every time I can a samll change in the application.
Comment 65 Vantage 2018-02-05 09:23:16 UTC
Please ignore my previous comment. Preview is also not working properly. I had to uninstall the app every time if I do a small change in the application.
Comment 66 Simba Mupfunya 2018-02-05 09:28:07 UTC
@Vantage, This issue was also in the patch we recieved but i didnt mind too much hoping that the preview and final release wont have the issue, i hope that the official release wont have this problem @Dean
Comment 67 Vantage 2018-02-05 09:33:22 UTC
@Simba - I am hoping the same because currently my development is hindered due to this.
Comment 68 dean.ellis 2018-02-05 10:24:48 UTC
If someone still has a problem with the Preview Release can they upload the diagnostic output, It might be we are hitting a slightly different problem.
Comment 69 Vantage 2018-02-05 11:42:51 UTC
@Dean - How may I generate it?
Comment 70 dean.ellis 2018-02-05 11:55:45 UTC
Take a look at https://developer.xamarin.com/guides/android/troubleshooting/troubleshooting/

Should give your the required steps for VS.
Comment 71 David 2018-02-05 12:37:24 UTC
Hi guys i'm new here and i'm having the same issues, what's working today? just change the dll or update to VS 15.6 preview 2? There's any prevision when this fix will come to everyone for VS2017?
Comment 72 Vantage 2018-02-05 13:12:30 UTC
@Dean - The diagnostic file is very large. Where should I send it?
Comment 73 Vantage 2018-02-05 13:14:39 UTC
@Dean, In the Build option in the Output Window, the last message are

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

But in the Debug option in the Output Window, the last message are
Android application is debugging.
Couldn't connect to logcat, GetProcessId returned: 0

Let me know if that helps.
Comment 74 dean.ellis 2018-02-05 13:15:26 UTC
If you can't attach it here gist.github.com should be able to take it
Comment 75 Vantage 2018-02-05 13:27:29 UTC
@Dean - https://gist.github.com/anonymous/e704af47b657a2b0a1058b1ebcce2914
Let me know if this works.
Comment 78 Pranoy Agrawal 2018-03-19 10:52:03 UTC
I am using VS Enterprise 15.6.2 and the patch was promised to be provided in 15.6 but I am still having same issues with my OnePlus 3 running on Oreo 8.0.
Please provide a solution to this problem ASAP.
Comment 79 Simba Mupfunya 2018-03-19 11:14:47 UTC
@Dean, i thought so too, was waiting patiently but its seems the fix didnt rollout with the update
Comment 80 Simba Mupfunya 2018-03-19 11:15:15 UTC
@Dean, i thought so too, was waiting patiently but its seems the fix didnt rollout with the update
Comment 81 dean.ellis 2018-03-19 11:37:35 UTC
So the fix we did ae7283b is in 15.6 , so if you are still having problems this must be a new issue which results in similar results. 

What we need to investigate is the diagnostic results of the following


`msbuild <project> /t:Install /v:diag /bl /p:Configursation=Debug > build.log`

This will produce a `build.log` and and `msbuild.binlog` which we can use to try to figure out what is going on.
Comment 82 Simba Mupfunya 2018-03-19 13:53:40 UTC
@Dean, so this is what happens: 

One a first time/clean deploy and debug all works as should. Then on an update the app is deployed and immediately the debugger stops with the message below

Android application is debugging.
Couldn't connect to logcat, GetProcessId returned: 0

After this failure the installed app soes not work, just hangs in suspended like state. I have a link to the build log generated after a small update.
Unistalling the app with render all well again.

https://microos.com/buildlog.txt
Comment 83 Mike Mekkils 2018-03-20 09:05:59 UTC
I can confirm the error Simba Mupfunya has.
Have the same effect. On second deployment the app is broken and won´t start anymore.

This is a completely different problem as the initial bug.
But seems to be OnePlus specific again. At least virtual machines are working somewhat correctly. (The 15.6 update generally has a lot of problems for me. Especially the nuget management is broken.)

I´m currently installing the update to 15.6.3, so I can´t create some logs at the moment. (Don´t know if it will help with some of my problems, because the change logs are only for 15.6 and not the updates...)

Is there going to be a new bug for this since this one is resolved? Or do we keep everything in here?
Comment 84 Nuno Mendes 2018-03-20 09:46:22 UTC
Hi,
I must say that since 15.6.2 update, I haven't got any more problems.
I can now do repeated builds / deploys on One Plus 3T running Oreo.
Many thanks! I was desperately waiting for this update.
For the others that continuing having problems, I agree that it must be another issue.
Comment 85 dean.ellis 2018-03-20 10:44:02 UTC
@Simba or @Mike

I looked at the log data @Simba posted and it is still re-installing the Mono Runtime.

can you run the following command from the Adb command prompt

adb shell "pm" "list" "packages" "-f"

and gist the list of packages it produces. It might be that our initial fix worked for most cases, but for some reason there is something slightly different about your devices.

It might be worth opening a new issue on 

https://github.com/xamarin/xamarin-android/issues

if it turns out to be a slightly different issue.
Comment 86 Simba Mupfunya 2018-03-20 11:09:08 UTC
@Dean below youll find the info

https://gist.github.com/Simba-Mupfunya/ade170a54734e0eea15ef4860d132678
Comment 87 dean.ellis 2018-03-20 13:37:30 UTC
That is really weird. The Debug Runtime is 

"package:/data/app/Mono.Android.DebugRuntime-W8JVsMyDj3WssfPB9n5k3Q==/base.apk=Mono.Android.DebugRuntime"

and the new code splits that correctly into 

"/data/app/Mono.Android.DebugRuntime-W8JVsMyDj3WssfPB9n5k3Q==/base.apk"

and 

"Mono.Android.DebugRuntime"

So can you attach the version information for the Xamarin.Android adding for VS. 
Also attach the `Mono.AndroidTools` to this bug from your Visual Studios MSBuild\Xamarin\Android directory. Note in VS2017 that is not just in Program Files x86 its in a directory specific to the edition you are using
Comment 88 Simba Mupfunya 2018-03-20 14:59:29 UTC
Created attachment 26221 [details]
Xamarin.Android

@Dean

Attached is my Mono.AndroidTools.dll file for VS2017 Professional(15.6.3) located in
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android

My Xamarin.android version is 8.2.0.16
Comment 89 dean.ellis 2018-03-20 15:21:00 UTC
@Simba

Thanks but that is the Xamarin.AndroidTools.dll we need the Mono.AndroidTools.dll :)
Comment 90 Simba Mupfunya 2018-03-20 15:38:07 UTC
Created attachment 26222 [details]
Mono.AndroidTools

@Dean indeed my mistake. Here we go!
Comment 91 dean.ellis 2018-03-21 09:10:31 UTC
ok your assembly has the fix.. this is really weird. 
I'll take another scan in the log and see if there is an issue elsewhere.
Comment 92 Simba Mupfunya 2018-03-21 09:35:34 UTC
@DEan i have produced some Xamarin diagnostics on intial deploy and debug and on subsequent runs: I hope this helps as well

Debug and Deploy Initial With Clean Install To OnePlus 3 Device (Xamarin Diagnostics - Working):
https://gist.github.com/Simba-Mupfunya/81abc3422ff832f0c38b18d7a7389209

Debug and Deploy nth time To OnePlus 3 Device no uninstall (Xamarin Diagnostics - Not Working):
https://gist.github.com/Simba-Mupfunya/f1588053ec9739ed66d00c5f229da49d