Bug 50354 - Deployment stuck at zipalign.exe
Summary: Deployment stuck at zipalign.exe
Status: NEEDINFO
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 7.0 (C8)
Hardware: PC Windows
: Highest critical
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-12-18 19:55 UTC by p.frass
Modified: 2018-02-26 20:18 UTC (History)
23 users (show)

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


Attachments
Output log of Visual Studio build (20.96 KB, text/plain)
2016-12-18 19:55 UTC, p.frass
Details
Xamarin Logs (4.61 KB, application/x-zip-compressed)
2017-03-30 16:16 UTC, Jeremy Kolb
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 50354 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:
NEEDINFO

Description p.frass 2016-12-18 19:55:44 UTC
Created attachment 18915 [details]
Output log of Visual Studio build

When I try to deploy my app to my phone, the process gets stuck at the zipalign.exe
The app is definitely working, because deployment on an emulator is working fine.
Comment 1 Jeremy Kolb 2017-03-30 16:14:25 UTC
I see this too.  Sometimes builds are stuck at the zipalign step for over 2 minutes.

2>C:\Users\jkolb\AppData\Local\Android\android-sdk\build-tools\25.0.2\zipalign.exe 4 "C:\Projects\EugsClient\EugsClient\EugsClient.Droid\bin\Debug\com.ara.eugsclient-Signed-Unaligned.apk" "bin\Debug\\com.ara.eugsclient-Signed.apk"
Comment 2 Jeremy Kolb 2017-03-30 16:16:51 UTC
Created attachment 21078 [details]
Xamarin Logs
Comment 3 Jeremy Kolb 2017-03-30 18:19:58 UTC
Jonathan Pryor,

This isn't an issue with zipalign.  It appears to be during the deploy process.  Build output hangs for minutes at the end of the following output:

2>C:\Users\jkolb\AppData\Local\Android\android-sdk\build-tools\25.0.2\zipalign.exe 4 "C:\Projects\EugsClient\EugsClient\EugsClient.Droid\bin\Debug\com.ara.eugsclient-Signed-Unaligned.apk" "bin\Debug\\com.ara.eugsclient-Signed.apk" 
2>Deleting file "C:\Projects\EugsClient\EugsClient\EugsClient.Droid\bin\Debug\com.ara.eugsclient-Signed-Unaligned.apk".
2>Detecting installed packages...
2>Copying application to device...
2>10% ... 960kb of 9531kb copied
2>20% ... 1920kb of 9531kb copied
2>30% ... 2880kb of 9531kb copied
2>40% ... 3840kb of 9531kb copied
2>50% ... 4800kb of 9531kb copied
2>60% ... 5760kb of 9531kb copied
2>70% ... 6720kb of 9531kb copied
2>80% ... 7680kb of 9531kb copied
2>90% ... 8640kb of 9531kb copied
2>100% ... 9531kb of 9531kb copied
Comment 4 soorosh_abi@hotmail.com 2017-03-31 05:37:52 UTC
ITNOA

I have the same problem, and zipalign.exe never finished.
Comment 5 Jeremy Kolb 2017-03-31 13:56:55 UTC
I may have a workaround (or it's the root of the problem?).  If you go into your developer settings on the phone and uncheck the verify apps over usb/adb does that fix it?  I looked at the adb logs and the phone was spending minutes validating the support library with dex2oat.
Comment 6 soorosh_abi@hotmail.com 2017-03-31 15:31:59 UTC
I have this problem in emulator too, I check this in Visual Studio 2017 Enterprise 15.0.0+26228.10 with Xamarin 4.3.0.784.
Comment 7 soorosh_abi@hotmail.com 2017-03-31 15:35:56 UTC
Visual Studio does not go further after zipalign.exe. and freez it.
Comment 8 soorosh_abi@hotmail.com 2017-04-02 07:50:25 UTC
I may have a workaround about this, If you install visual studio 2015 previously and uninstall it and install visual studio 2017, this problem raised, so for resolved this problem you must removed Xamarin and android sdk completely from your computer and install again visual studio 2017.
Comment 9 softlion 2017-04-07 09:17:35 UTC
+1
Comment 10 soorosh_abi@hotmail.com 2017-05-26 15:30:30 UTC
Hi again, I still have this problem in Visual Studio 2017 15.2 with Xamarin 4.5.0.433. please consider this problem as a bug and resolve it. thanks
Comment 11 Eduardo Carísio 2017-06-02 01:21:23 UTC
Same here...
Visual Studio 2017 15.2 with Xamarin 4.5.0.476
Comment 12 Heinrich Braasch 2017-06-02 02:27:59 UTC
Same here ...
For me this problem occurs when deploying to an ACTUAL device, directly after a clean build. It is fine on simulators. The deploy process waits up to at least 5 min at:
2>Copying application to device...
2>10% ... 832kb of 7688kb copied
2>20% ... 1600kb of 7688kb copied
2>30% ... 2368kb of 7688kb copied
2>40% ... 3136kb of 7688kb copied
2>50% ... 3904kb of 7688kb copied
2>60% ... 4672kb of 7688kb copied
2>70% ... 5440kb of 7688kb copied
2>90% ... 6976kb of 7688kb copied
2>100% ... 7688kb of 7688kb copied

I got these log output by setting Options=>Projects and Solutions => Build and Run => MSBuild project build output verbosity => Detailed

After a while it then carries on. Thereafter, if I do not clean the solution (forcing a clean build), the deploy happens fast.

This problem started occurring after a recent upgrade to latest version of VS (sitting currently at VS 2017 15.2 (26439.12)) Xamarin 4.5.0.476

This is definitely a bug that PLEASE needs some serious attention.
Comment 13 Cody Beyer (MSFT) 2017-06-13 21:55:45 UTC
Confirming this issue as it is periodically reproducible on my system. Unclear at this point if the issue falls within the purview of Android or the Visual Studio extension (issue does not occur using VS for Mac)
Comment 14 Jan Göltenboth 2017-06-23 16:39:45 UTC
I'm facing the same issue with VS 15.2 and the latest preview of VS2017. I tried both, the latest android sdk v26 and v25..none of these worked. The first time after reinstalling either 15.2 or preview the deployment works once but starts hanging in the future deployments.
Comment 15 Lance 2017-06-23 17:06:25 UTC
For anyone having issues here still, try this: (I think this was how I fixed it.)

- Uninstall the app from the physical device you're trying to deploy to,
- Turn off, and restart the device,
- Then clean and rebuild/redeploy after the device has restarted

NOTES: This issue only happened on physical devices for me, although you might try these steps with the emulator as well if you're having issues there.

I believe I ended up reading somewhere that this issue occurs in corner-case situations when the build/deploy process gets hung trying to locate the old version of the app before installing the new one.

If these steps fix your issue, make sure in the future that when you build/deploy, that the device is UNLOCKED. The lock screen seems to be an issue at play here.

Hope this helps someone.
Comment 16 Jan Göltenboth 2017-06-23 17:14:32 UTC
@Lance thanks for your help. I remember that I've exactly applied your steps earlier today when the deployment worked (once). I thought it could deploy due to the re-installation of VS 15.2 / 15.3 preview. But once the deployment succeeded it did not work a second or third time. I assume I'd have to go through your steps before each deployment :-/... I'll test your suggestion and provide feedback later on.
Comment 17 Jan Göltenboth 2017-06-23 20:42:52 UTC
I can confirm the steps suggested by @Lance are a valid workaround for now till its fixed.

In my case the app hangs at one of these deployment steps (without applied steps from above):

 > Project "***.csproj" (Install target(s)):
 > 5>C:\Program Files (x86)\Android\android-sdk\build-tools\25.0.3\zipalign.exe 4 "C:\repos\***\src\***\***.Mobile.Android\bin\Debug\com.***.***-Signed-Unaligned.apk" "bin\Debug\\com.poinfo.mobile-Signed.apk" 

I am currently using the following configuration:
 > VS: 2017, 15.2 (26430.14)
 > Build-Tools: 25.0.3
 > Xamarin: 4.5.0.486
 > Xamarin.Android.SDK: 7.3.1.2

As already mentioned, deployment only works when following these steps (Step 1 and 2 may be switched):
 1. Delete app on device
 2. Restart device
 3. Clean Android solution
 4. Deploy

Since this issue also appears on my VS 15.0 instance (which worked fine in the past), I assume the problem is somewhere in the android tooling or some cached magic which I am not aware of :-)....
Comment 18 Cliff Hudson 2017-06-30 22:47:30 UTC
I was also having this problem with the emulator.  There was another version of the app with the same name on the emulator.  In Settings on the emulated device, I uninstalled the app and was then able to successfully deploy the app.

My Setup:

Microsoft Visual Studio Community 2017 
Version 15.2 (26430.14) Release
VisualStudio.15.Release/15.2.0+26430.14
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Community

Visual Basic 2017   00369-60000-00001-AA202
Microsoft Visual Basic 2017

Visual C# 2017   00369-60000-00001-AA202
Microsoft Visual C# 2017

Visual C++ 2017   00369-60000-00001-AA202
Microsoft Visual C++ 2017

Visual F# 4.1   00369-60000-00001-AA202
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.6.00404.2
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30503.0
ASP.NET and Web Tools 2017

ASP.NET Web Frameworks and Tools 2017   5.2.50303.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30209.0
Azure App Service Tools v3.0.0

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

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

KofePackagePackage Extension   1.0
KofePackagePackage Visual Studio Extension Detailed Info

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50131.1

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.

Node.js Tools   1.3.50417.1
Adds support for developing and debugging Node.js apps in Visual Studio

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

SQL Server Data Tools   15.1.61702.140
Microsoft SQL Server Data Tools

Syntax Highlighting Pack   2.7.125
Adds syntax highlighting and snippet support for a wide variety of programming languages such as Clojure, Go, Jade, Lua, Swift, Ruby and many more...

TypeScript   2.2.2.0
TypeScript tools for Visual Studio

Visual Studio tools for CMake   1.0
Visual Studio tools for CMake

Visual Studio Tools for Unity   3.1.0.0
Visual Studio Tools for Unity

Xamarin   4.5.0.486 (fec6f88)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.3.1.2 (9dbc4c5)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.10.0.37 (ad35de4)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 19 Jon Douglas [MSFT] 2017-07-14 15:48:48 UTC
Does anyone CC'd on this bug have a reproduction project that demonstrates this behavior? Although I've ran into this in the past, it's typically because of another hang in the deployment process and zipalign is the last task in APK creation. i.e. zipalign is ran after the APK is signed. I have however seen reports where zipalign is the hanging process and it actually fails internally, but we do not exit from it as soon as it fails.

This perhaps could be fixed using apksigner as per my bug report here: https://bugzilla.xamarin.com/show_bug.cgi?id=57914

I'm asking for any additional help in pinpointing this issue as it's not a 100% reproducible situation. Basically once I can get a reproduction project or at least an environment in which I can reproduce, I can dig further into this MSBuild target/task and indicate whether zipalign is working / failing and see what's going on for these situations where there is a hang.
Comment 20 Jeremy Kolb 2017-07-14 15:55:53 UTC
I don't think the reproduction of this bug is project based.  It seems to happen to me intermittently and/or gets progressively worse.

I've seen a few cases where the device spends AGES verifying the APK while Xamarin reports that it's stuck at zipalign.
Comment 21 Lance 2017-07-14 16:11:16 UTC
Agree with Jeremy.

Additionally, my suspicion tells me that this is likely due to the way the device stops/restarts the app. It seems that this happens most commonly when the build process begins looking for the currently installed app, in order to kill and replace it's installation. Almost as if it's looking for a running instance that doesn't exist. I believe that's why restarting the physical device seems to solve the issue. Some sort of identifier mismatch maybe?

I can't substantiate my claims yet, but when I have some downtime I will try to investigate and repro the issue through corner case actions, etc.
Comment 22 Philipp Sumi 2017-08-07 16:02:32 UTC
As far as repro projects go: I'm seeing this on my main dev machine while I don't have the issue on my laptop, so this seems to be an environment or Xamarin issue.
Comment 23 softlion 2017-08-07 16:12:00 UTC
I can repro this when:
- using android emus
- no emu is launched
- using ctrl F5

The common pattern is that
The emu is not launched
When it happens.
Comment 24 softlion 2017-08-09 17:35:42 UTC
Log when it happens:

1>  Found AndroidNdk at C:\Dev\android-sdk
1>dk-bundle
1>  Found AndroidTools at C:\Dev\android-sdk\tools
1>DEBUG RunShellCommand emulator-5554 getprop
1>TASK: GetProperties getprop completed?:[dalvik.vm.dex2oat-Xms]: [64m]
1>[dalvik.vm.dex2oat-Xmx]: [512m]
1>[dalvik.vm.heapsize]: [384m]
1>[dalv...

(locked here, only way to go out is CTRL-BREAK)
Comment 25 softlion 2017-08-15 06:55:10 UTC
Same problem with 15.3

Only on first start of emulator 
Emulator settings:


(Android 5.1 API 22 Google version)

avd.ini.encoding=UTF-8
AvdId=Nexus_5X_API_22
abi.type=x86_64
avd.ini.displayname=Nexus 5X API 22
avd.ini.encoding=UTF-8
disk.dataPartition.size=1000M
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera.back=emulated
hw.camera.front=emulated
hw.cpu.arch=x86_64
hw.cpu.ncore=4
hw.dPad=no
hw.device.hash2=MD5:77580bb7bfa79229a4dc90909e7ad6b9
hw.device.manufacturer=Google
hw.device.name=Nexus 5X
hw.gps=yes
hw.gpu.enabled=yes
hw.gpu.mode=auto
hw.initialOrientation=Portrait
hw.keyboard=no
hw.lcd.density=420
hw.lcd.height=1920
hw.lcd.width=1080
hw.mainKeys=no
hw.ramSize=1536
hw.sdCard=yes
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images\android-22\google_apis\x86_64\
runtime.network.latency=none
runtime.network.speed=full
showDeviceFrame=yes
skin.dynamic=yes
skin.name=nexus_5x
skin.path=C:\Dev\android-sdk\skins\nexus_5x
tag.display=Google APIs
tag.id=google_apis
vm.heapSize=256
Comment 27 Alper Ebicoglu 2017-09-25 07:49:36 UTC
i have solved the problem with  removing Bin & Obj output folders. by the way sometimes installed app should be uninstalled from target device (if signature of apk has changed)
Comment 30 Jon Douglas [MSFT] 2018-01-04 23:21:34 UTC
Bumping priority due to the nature of a blocking deployment bug. We are still investigating a reliable reproduction and if anyone has one, please upload this to the bug report. Thank you!
Comment 31 D Fineout 2018-01-14 21:31:31 UTC
+1 this is blocking me from using my Windows dev machine. I'll try my Mac once home but assume this will also be a blocker for other devs on my team. 

About VS info pasted below:

Microsoft Visual Studio Enterprise 2017
Version 15.4.2
VisualStudio.15.Release/15.4.2+27004.2006
Microsoft .NET Framework
Version 4.7.02556

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools   00369-60000-00001-AA837
Microsoft Architecture Diagrams and Analysis Tools

Visual Basic 2017   00369-60000-00001-AA837
Microsoft Visual Basic 2017

Visual C# 2017   00369-60000-00001-AA837
Microsoft Visual C# 2017

Visual C++ 2017   00369-60000-00001-AA837
Microsoft Visual C++ 2017

Visual F# 4.1   00369-60000-00001-AA837
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.9.00809.2
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30925.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017   5.2.50921.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30915.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio

Azure Data Lake Tools for Visual Studio   2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio

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

Dotfuscator Community Edition   5.30.0.5167-c98e2f8
PreEmptive Protection - Dotfuscator CE

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

GitHub.VisualStudio   2.2.0.10
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

JetBrains ReSharper Ultimate 2017.1.2    Build 108.0.20170428.75743
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2018 JetBrains, Inc.

MenuCommands Extension   1.0
MenuCommands Visual Studio Extension Detailed Info

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node   2.2.9000.1
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.2.9000.1
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio   1.8
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service   2.2.9000.1
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50719.1

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.7.4-pre (c2d89eb)
Support for debugging Mono processes with Visual Studio.

Node.js Tools   1.4.10918.1
Adds support for developing and debugging Node.js apps in Visual Studio

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

Office Developer Tools for Visual Studio 2017 ENU   15.0.26818
Microsoft Office Developer Tools for Visual Studio 2017 ENU

Redgate ReadyRoll   1.14.17.5347
Extend DevOps processes to your SQL Server databases and safely automate database deployments.
    
Visit https://www.red-gate.com/readyroll for more information.

Copyright (C) 2011 Red Gate Software Ltd. All rights reserved.
  
This software contains components from Component Owl.
SQL Server is a registered trademark of Microsoft Corporation. 
Visual Studio is a registered trademark of Microsoft Corporation. 

ReadyRoll contains code from the following open source software:

NuGet https://www.nuget.org/
SQL LocalDB Wrapper https://github.com/martincostello/sqllocaldb
Autofac https://autofac.org/
Json.NET https://json.net/
MahApps.Metro http://mahapps.com/
SemVer https://github.com/maxhauser/semver
Log4Net http://logging.apache.org/log4net/
Extended WPF Toolkit https://wpftoolkit.codeplex.com/
Code InfoBox VSX http://www.codeproject.com/Articles/55196/Code-InfoBox-Visual-Studio-Extension-VSX
OctoPack https://github.com/OctopusDeploy/OctoPack
SQLite https://sqlite.org/

This product contains icons from http://www.visualpharm.com distributed under a free backlink license.

For license details or other notices relating to the above software, please see NOTICE.TXT and EULA.rtf in the ReadyRoll application folder.
    

Redgate SQL Prompt   8.2.1.2615
Write, format, and refactor SQL effortlessly

SQL Server Data Tools   15.1.61707.200
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   2.3.5.0
TypeScript tools for Visual Studio

Visual C++ for Cross Platform Mobile Development (Android)   15.0.26823.01
Visual C++ for Cross Platform Mobile Development (Android)

Visual C++ for Cross Platform Mobile Development (iOS)   15.0.26823.01
Visual C++ for Cross Platform Mobile Development (iOS)

Visual C++ for Linux Development   1.0.8
Visual C++ for Linux Development

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Apache Cordova   15.120.6728.2
Visual Studio Tools for Apache Cordova

Visual Studio tools for CMake   1.0
Visual Studio tools for CMake

Visual Studio Tools for Universal Windows Apps   15.0.27004.2006
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VisualStudio.IoT   1.0
Package with IoT components for Visual Studio

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSColorOutput   2.5.1
Color output for build and debug windows - http://mike-ward.net/vscoloroutput

WebJobs Tools v1.0.0   15.0.30915.0
WebJobs Tools v1.0.0

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

Xamarin   4.7.10.33 (70936af)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   8.0.2.1 (HEAD/c2a33d8ea)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.2.1.0 (12e80e0)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 32 D Fineout 2018-01-14 21:33:07 UTC
Also, happy to provide a reproduction. Please indicate which recording tool/format will be most useful for you.
Comment 33 ThorvaldBoe 2018-02-01 17:25:29 UTC
This error is killing me! I have tried every suggestion in this and other posts, with no other solution than restarting my device every time it occurs (which suddenly has become very often).

Don't know if it is of any help, but by setting detailed log level, I noticed that the command running just before it hangs, is:

adb shell am broadcast -a "mono.android.intent.action.PACKAGE_VERSIONS" -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_25,nl.natuurnetwerk.notifier" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions"

When running this in a command prompt, I get:
C:\Program Files (x86)\Android\android-sdk\platform-tools>adb shell am broadcast -a "mono.android.intent.action.PACKAGE_VERSIONS" -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_25,nl.natuurnetwerk.notifier" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions"
Broadcasting: Intent { act=mono.android.intent.action.PACKAGE_VERSIONS cmp=Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } (has extras) }


After a while, it responds:

Broadcast completed: result=0, data="Mono.Android.DebugRuntime=1515628258,Mono.Android.Platform.ApiLevel_25=1515594562,"

That is, when everything is working. When this error occurs, the "Broadcast completed" section does not appear.

I assume that the build process is somehow stuck waiting for the response. I have no idea what the command is doing, or why the response is missing, though.
Comment 34 Jonathan Pryor 2018-02-02 18:48:21 UTC
> I assume that the build process is somehow stuck waiting for the response.

That is correct.


> I have no idea what the command is doing

The `mono.android.intent.action.PACKAGE_VERSIONS` broadcast requests the versions of applications installed on the target device. It's used to determine:

* Whether the application is already installed (package name isn't listed in output if it's not installed), and

* Whether the application needs to be updated.

> , or why the response is missing, though.

It's missing presumably because it hasn't returned.

This is also troubling:

> After a while, it responds:

That command isn't expected to "take awhile." It's expected to be close to instantaneous, and other parts of the system require/assume that as well.

If the broadcast *isn't* "fast," there will be many knock-on effects, which is rather troubling...
Comment 35 Jonathan Pryor 2018-02-02 19:01:52 UTC
@ThorvaldBoe: Possible workaround: hand-edit your app.csproj, and in the Debug configuration set:

$(AndroidUseSharedRuntime)=False
$(EmbedAssembliesIntoApk)=False

This should disable use of the shared runtime -- which I *think* is what requires the `PACKAGE_VERSIONS` broadcast, though I haven't tested this -- while enabling the core part of fast deployment. In this case, *all* assemblies will be fast deployed, not just the application assemblies.

Hopefully this will increase the reliability of your IDE experience.
Comment 36 ThorvaldBoe 2018-02-03 12:09:58 UTC
Thanks, Jonathan, for your suggestions and informative comments.

I have already tried removing the fast deployment and shared runtime options. However, in VS they are connected, so you cannot have fast deployment checked (EmbedAssembliesIntoApk=false) without shared runtime when using the android options GUI in VS. So what you are suggesting, is to hand-edit a combination of options that is not allowed in GUI. That is very interesting, and certainly not something I would have thought of myself :)

I will try it out and let you know how it went.

As to your comments regarding the package_versions command, I noticed a big variation in response time from that command. Many times, as you said, it would return immediately. Other times, it would take 2-3 seconds. And at a few occasions, it took something like 30 seconds. 

I tried reading up a bit on the ADB commands, to see if I could find a set of commands that would somehow reset the device when this problem happened. I tried various commands in the start/stop/reset/kill kategory, but as I don't really understand what I am doing, it was a long shot and nothing I tried worked. Would have been great if I found a command that would spare me from the hassle of restarting the device though.

Another though, which is also a guess, is that these problems are somehow related to background services. The reason I think so, is that for me, the problems started when I implemented geofence functionality in my app, connected to a background service. It also seemed that the problem would occur more often when I did the following:
1.Debugging the app on the device
2.Switching to another app for setting fake GPS position
3.Stopping the debugging while remaining in the other app
But I have not found a way for a consistent reproduction, so this might just be my imagination.
Comment 37 ThorvaldBoe 2018-02-12 13:59:31 UTC
I tried Jonathan's suggestions, but can unfortunately confirm that there is still a problem. 

What is strange though, is that while leaving my pc running, I discovered that after a couple of minutes (5 or so), I got passed the original problem step:

am broadcast -a "mono.android.intent.action.PACKAGE_VERSIONS"...

But now it is stuck at this step:

am broadcast -a "mono.android.intent.action.EXTERNAL_STORAGE_DIRECTORY" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.ExternalStorageDirectory"

For curiosity, I left the process running while doing something else, and as I suspected, after about 5 more minutes VS SAID it was debugging the application, but nothing happened on the device. When stopping the application, VS complained about not being able to contact the device, and hung for about 2 minutes before returning to normal. The same thing will now happen every time I try to run the app, until I restart the device.

In order to provoke the error, I do the following:
-I start debugging my app on the device (Samsung J5)
-I switch to another app (fake GPS free) and set some fake coordinates
-I stopp debugging while still in the fakeGPS app
It is not consistent, but after doing this several times, it is almost guaranteed to reach the problem state. I am using geofencing in my app, and suspect the error might be related to either geofencing, gps or running a background service, as it seems to be stable when not using these features.

I hope this is helpful in solving the problem.
Comment 38 Gaurav 2018-02-26 20:18:47 UTC
Any update on this issue. I am facing the very same issue on VS android emulator, the device works just fine - 
 - I have recently formatted my system and did a fresh install of VS 2017
 - Opened an existing app of mine in VS
 - Tried to run the app in VS emulator for Android
 - It got stuck at zipalign 
 - After trying several time I gave up
 - Connected my Amazon Fire tab(new) and it worked

I am dependent upon emulator as I cannot use the tab every time.