2
votes

When building a Xamarin Android project we sporadically get these exceptions. Any ideas how to remove the flakiness? Is this even solvable on our side or looks like an Xamarin Android bug?

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000: Unhandled exception: System.IO.IOException: Sharing violation on path /Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/obj/Release/android/src/com/google/android/gms/R.java [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int) [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tools.Files.CopyIfStreamChanged (System.IO.Stream stream, System.String destination) [0x0002b] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.MonoAndroidHelper.CopyIfStreamChanged (System.IO.Stream source, System.String destination) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.GenerateLibraryResources.GenerateJava (Xamarin.Android.Tasks.GenerateLibraryResources+Library library) [0x0029c] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.AsyncTaskExtensions+<>c__DisplayClass0_0`1[TSource].<ParallelForEach>b__0 (TSource s) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000: Unhandled exception: System.IO.IOException: Sharing violation on path /Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/obj/Release/android/src/com/google/android/gms/base/R.java [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int) [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tools.Files.CopyIfStreamChanged (System.IO.Stream stream, System.String destination) [0x0002b] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.MonoAndroidHelper.CopyIfStreamChanged (System.IO.Stream source, System.String destination) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.GenerateLibraryResources.GenerateJava (Xamarin.Android.Tasks.GenerateLibraryResources+Library library) [0x0029c] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.AsyncTaskExtensions+<>c__DisplayClass0_0`1[TSource].<ParallelForEach>b__0 (TSource s) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]

We checked that the build agent has selected a valid $(TargetFrameworkVersion) and the required android api-level is installed in $(AndroidSdkDirectory)\platforms. We use Android 10 for the target framework version and SDK 29 is installed in /Users/Shared/Development/Android/sdk/platforms/android-29.

Visual Studio Version:

=== Visual Studio Community 2019 for Mac ===

Version 8.4 (build 2657) Installation UUID: 59b142d8-4988-47b4-b8f6-69df598d76b6 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 5.16.1.25 (issue-7441-d16-3-vsmac / 881172e73)

Package version: 606000155

=== Mono Framework MDK ===

Runtime: Mono 6.6.0.155 (2019-08/296a9afdb24) (64-bit) Package version: 606000155

=== Roslyn (Language Service) ===

3.4.0-beta4-19562-05+ff930dec4565e2bc424ad3bf3e22ecb20542c87d

=== NuGet ===

Version: 5.3.0.6192

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.100/Sdks SDK Versions: 3.1.100 2.1.802 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.6.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 3.1.0 2.1.14 2.1.13

=== Xamarin.Profiler ===

Version: 1.6.12.29 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.3 (15712) Build 11C504

=== Xamarin.Mac ===

Version: 6.8.3.0 (Visual Studio Community) Hash: 0d8fe219c Branch: d16-4 Build date: 2019-12-04 13:06:40-0500

=== Xamarin.iOS ===

Version: 13.8.3.0 (Visual Studio Community) Hash: 0d8fe219c Branch: d16-4 Build date: 2019-12-04 13:06:41-0500

=== Xamarin Designer ===

Version: 16.4.0.468 Hash: 519082ea8 Branch: remotes/origin/d16-4 Build date: 2019-12-04 16:21:00 UTC

=== Xamarin.Android ===

Version: 10.1.1.0 (Visual Studio Community) Commit: xamarin-android/d16-4/f2c9364 Android SDK: /Users/Shared/Development/Android/sdk Supported Android versions: 8.0 (API level 26) 8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 29.0.4 SDK Build Tools Version: 29.0.2

Build Information: Mono: bef1e63 Java.Interop: xamarin/java.interop/d16-4@c4e569f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.28.0@46204c4 Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/Shared/Development/jdk/microsoft_dist_openjdk_8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.4.0.9 Hash: 3f7256f Branch: remotes/origin/d16-4 Build date: 2019-12-19 18:59:12 UTC

=== Android Device Manager ===

Version: 16.4.0.28 Hash: 68e9956 Branch: remotes/origin/d16-4 Build date: 2019-12-19 18:59:32 UTC

=== Xamarin Inspector ===

Version: 1.4.3 Hash: db27525 Branch: 1.4-release Build date: Mon, 09 Jul 2018 21:20:18 GMT Client compatibility: 1

=== Build Information ===

Release ID: 804002657 Git revision: 4c6723413e884e024466fc93ff10e938bca7f721 Build date: 2020-01-06 18:20:13+00 Build branch: release-8.4 Xamarin extensions: 0f572cad12fd3886cd8e21a8b93b86e29ceaf111

=== Operating System ===

Mac OS X 10.15.2 Darwin 19.2.0 Darwin Kernel Version 19.2.0 Sat Nov 9 03:47:04 PST 2019 root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

1
If you move your project from VS-for-mac to the VS windows. Rebuild you project, if this issue is still existed. Can you re-back to the previous version?Leon Lu - MSFT
We do not have the infrastructure to switch to Visual Studio for Windows.Christopher Stephan
Can you share a demo that could reproduce this issue?Leon Lu - MSFT
We did not spend time in trying to find a small reproducible example yet. Based on this we try to update nuget packages that have dependencies Xamarin.Build.Download with a version smaller than 0.8.0.Christopher Stephan
Thank you for your support. We could not reproduce the error after updating Xamarin.Build.Download to version 0.8.0.Christopher Stephan

1 Answers

3
votes

After updating package Xamarin.Build.Download from version 0.7.1. to 0.8.0 we could not reproduce this error. We also updated packages that had this library as a dependency. In our case these were Xamarin.Firebase.Analytics and Xamarin.Android.Crashlytics.