Xamarin-android: FastDeploy.DeployFileWithFastDevTool failed with "Could not find file "/.../MyApp/obj/Debug/android/assets/Acr.UserDialogs.dll.mdb" error

Created on 16 Feb 2021  路  20Comments  路  Source: xamarin/xamarin-android

Steps to Reproduce

  1. Create a Xamarin.Forms app
  2. Reference Acr.UserDialogs 7.0.35 package (the version is important, the latest version of the package works)
  3. Run the Android target on an Android device (or emulator)

Expected Behavior

The app is built and deployed to the device

Actual Behavior

The app is built but the deployment step fails with FastDeploy.DeployFileWithFastDevTool failure:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(586,5): error : Could not find file "/Users/my_user/Desktop/Sources/MyApp/Droid/obj/Debug/android/assets/Acr.UserDialogs.dll.mdb"
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(586,5): error :   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) [0x00259] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/FileStream.cs:274 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(586,5): error :   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/FileStream.cs:91 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(586,5): error :   at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(586,5): error :   at System.IO.File.OpenRead (System.String path) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/System.IO.FileSystem/src/System/IO/File.cs:266 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(586,5): error :   at Xamarin.Android.Tasks.FastDeploy.DeployFileWithFastDevTool (Microsoft.Build.Framework.ITaskItem file, System.String toolPath, System.String overridePath, System.Byte[] buffer, System.Byte[] compressed, K4os.Compression.LZ4.LZ4Level lz4level) [0x00061] in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:594 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(586,5): error :   at Xamarin.Android.Tasks.FastDeploy.DeployFastDevFiles (System.String toolPath, System.String overridePath) [0x0061c] in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:573 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(586,5): error :   at Xamarin.Android.Tasks.FastDeploy.RunTaskAsync () [0x00574] in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:223 
    4 Warning(s)
    1 Error(s)

Version Information

=== Visual Studio Enterprise 2019 for Mac (Preview) ===

Version 8.9 Preview (8.9 build 1593)
Installation UUID: 197b4b8d-2a9a-4fbd-896c-cd74849affd3
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

    Package version: 612000122

=== Mono Framework MDK ===

Runtime:
    Mono 6.12.0.122 (2020-02/c621c35ffa0) (64-bit)
    Package version: 612000122

=== Roslyn (Language Service) ===

3.9.0-4.21104.8+2fc92d84e746c3aab75f0930278ea6675cd5bb5c

=== NuGet ===

Version: 5.8.0.6860

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.103/Sdks
SDK Versions:
    5.0.103
    5.0.102
    5.0.101
    5.0.100
    5.0.100-rc.2.20479.15
    3.1.406
    3.1.405
    3.1.404
    3.1.403
    3.1.402
    3.1.401
    3.1.302
    3.1.301
    3.1.300
    3.1.201
    3.1.200
    3.1.102
    3.1.100
    3.1.100-preview3-014645
    3.1.100-preview2-014569
    3.0.100
    2.1.701
    2.1.700
    2.1.505
    2.1.504
    2.1.500
    2.1.402
    2.1.302
    2.1.301
    2.1.4
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    5.0.3
    5.0.2
    5.0.1
    5.0.0
    5.0.0-rc.2.20475.5
    3.1.12
    3.1.11
    3.1.10
    3.1.9
    3.1.8
    3.1.7
    3.1.6
    3.1.5
    3.1.4
    3.1.3
    3.1.2
    3.1.0
    3.1.0-preview3.19553.2
    3.1.0-preview2.19525.6
    3.0.0
    2.1.23
    2.1.22
    2.1.21
    2.1.20
    2.1.19
    2.1.18
    2.1.17
    2.1.16
    2.1.15
    2.1.14
    2.1.13
    2.1.12
    2.1.11
    2.1.9
    2.1.8
    2.1.6
    2.1.4
    2.1.2
    2.1.1
    2.0.5

=== .NET Core 3.1 SDK ===

SDK: 3.1.406

=== Xamarin.Profiler ===

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

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 12.4 (17801)
Build 12D4e

=== Xamarin.Mac ===

Version: 7.8.1.0 (Visual Studio Enterprise)
Hash: 17845a189
Branch: d16-9
Build date: 2021-01-26 03:42:37-0500

=== Xamarin.iOS ===

Version: 14.14.1.0 (Visual Studio Enterprise)
Hash: 17845a189
Branch: d16-9
Build date: 2021-01-26 03:42:38-0500

=== Xamarin Designer ===

Version: 16.9.0.309
Hash: 9a5259fb5
Branch: remotes/origin/9a5259fb55e54a445c145ab5ea29c04a418deed2
Build date: 2021-02-04 09:34:28 UTC

=== Xamarin.Android ===

Version: 11.2.0.0 (Visual Studio Enterprise)
Commit: xamarin-android/d16-9/f908d16
Android SDK: /Users/astrakh/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        5.0 (API level 21)
        5.1 (API level 22)
        6.0 (API level 23)
        7.1 (API level 25)
        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: 5e9cb6d
Java.Interop: xamarin/java.interop/d16-9@1d382be
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.32.2@cfe06e0
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@ad80a42

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/astrakh/Library/Developer/Xamarin/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.9.0.21
Hash: 57e40ba
Branch: remotes/origin/main
Build date: 2021-01-08 01:57:14 UTC

=== Android Device Manager ===

Version: 16.9.0.14
Hash: 0fdccda
Branch: remotes/origin/main
Build date: 2021-01-08 01:57:36 UTC

=== Build Information ===

Release ID: 809001593
Git revision: bf434e0df6f858da3d221515385acb8fe80b622a
Build date: 2021-02-11 10:01:48-05
Build branch: release-8.9
Xamarin extensions: bf434e0df6f858da3d221515385acb8fe80b622a

=== Operating System ===

Mac OS X 10.16.0
Darwin 20.2.0 Darwin Kernel Version 20.2.0
    Wed Dec  2 20:39:59 PST 2020
    root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

XAML Styler 2.0.1
Xamarin Hot Reload 20190830.17


Log File

deployment-new.log

App+Library Build

Most helpful comment

So the workaround target does work

Removed Item(s): _ResolvedSymbols=obj\Debug\100\android\assets\Zambezi.dll.mdb

But the format of the command is missing files like Microsoft.IdentityModel.Clients.ActiveDirectory.dll.mdb because of the multiple periods. A new target which handles this scenario is below.

<Target Name="_RemoveMdbFiles" BeforeTargets="_Upload">
    <ItemGroup>
        <_Temp Include="%(_ResolvedSymbols.Identity)" Condition="'%(_ResolvedSymbols.Extension)' == '.mdb'" />
        <_ResolvedSymbols Remove="@(_Temp)"/>
    </ItemGroup>
</Target>

All 20 comments

Should be fixed by xamarin/monodroid#1166

Oh good, because I have the same problem with almost every nuget package I use. Your link is not working though?

The link is to a private repo.
The best workaround is to upgrade your nuget package. The reason it happens is there are some old nugets still using the old pdb format. These have to be converted to mdb files for the debugger to use them. All of the new projects should be using the portable pdb format which the native runtime has built in support for. So if you can upgrade the problem packages.

I already submitted a PR to Acr.UserDialogs to change PDB to portable and this is already merged. So use last nuget and be happy

This workaround has been replaced with https://github.com/xamarin/xamarin-android/issues/5631#issuecomment-794289675

The fix for this was merged and included in this bump https://github.com/xamarin/xamarin-android/pull/5645. It should be in d16-10 P2. Please reopen if you find a case where none of the workarounds work.

A workaround for people who cannot get an updated nuget package to fix the issue

<Target Name="_RemoveMdbFiles" BeforeTargets="_Upload">
    <ItemGroup>
        <_ResolvedSymbols Remove="**/*.dll.mdb" />
    </ItemGroup>
</Target>

add this to the bottom of your csproj just above the </Project> element.

Tried this, but still getting the same issue. with Xamarin.Auth.dll.mdb

Tried this, but still getting the same issue. with Xamarin.Auth.dll.mdb

I think this lib is dead. Check if Xamarin.Essentials has the API you need or fork the lib and change debug type on your own

@dileep-maxpro do you have a diagnostic build log we can take a look at? The best way to get one is via

msbuild <your Android csproj> /restore /t:Install /bl /p:_FastDeploymentDiagnosticLogging=true

That should produce a msbuild.binlog file. You can then zip this up and attach it to this Issue.

msbuild.zip

A workaround for people who cannot get an updated nuget package to fix the issue

<Target Name="_RemoveMdbFiles" BeforeTargets="_Upload">
    <ItemGroup>
        <_ResolvedSymbols Remove="**/*.dll.mdb" />
    </ItemGroup>
</Target>

add this to the bottom of your csproj just above the </Project> element.

This unfortunately didn't work for me. It apparently compiles but I'm getting this when I attempt to deploy:

Could not find file '<project path>\obj\Debug\100\android\assets\Microsoft.IdentityModel.Clients.ActiveDirectory.dll.mdb'.

Attempting to run the above msbuild command failed with the same error and a build log that I have attached. I'm not directly referencing this package anywhere as far as I can see.

I am having the exact same issue as @louisoftokyo.

So the workaround target does work

Removed Item(s): _ResolvedSymbols=obj\Debug\100\android\assets\Zambezi.dll.mdb

But the format of the command is missing files like Microsoft.IdentityModel.Clients.ActiveDirectory.dll.mdb because of the multiple periods. A new target which handles this scenario is below.

<Target Name="_RemoveMdbFiles" BeforeTargets="_Upload">
    <ItemGroup>
        <_Temp Include="%(_ResolvedSymbols.Identity)" Condition="'%(_ResolvedSymbols.Extension)' == '.mdb'" />
        <_ResolvedSymbols Remove="@(_Temp)"/>
    </ItemGroup>
</Target>

@dan-SLT

can you provide the diagnostic output using the command outlined in https://github.com/xamarin/xamarin-android/issues/5631#issuecomment-793708205.

@dan-SLT

can you provide the diagnostic output using the command outlined in #5631 (comment).

Running what you requested I get the errors below.

MSBUILD : error MSB1005: Specify a property and its value.
Switch: /p:

MSBUILD : error MSB1008: Only one project can be specified.
Switch: _FastDeploymentDiagnosticLogging=true

@dan-SLT

There was a typo in the command there was a space between /p: and _FastDeploymentDiagnosticLogging=true.
The actual command is.

msbuild <your Android csproj> /restore /t:Install /bl /p:_FastDeploymentDiagnosticLogging=true

So the workaround target does work

Removed Item(s): _ResolvedSymbols=obj\Debug\100\android\assets\Zambezi.dll.mdb

But the format of the command is missing files like Microsoft.IdentityModel.Clients.ActiveDirectory.dll.mdb because of the multiple periods. A new target which handles this scenario is below.

<Target Name="_RemoveMdbFiles" BeforeTargets="_Upload">
    <Message Text="%(_ResolvedSymbols.Extension)" />
    <ItemGroup>
        <_Temp Include="%(_ResolvedSymbols.Identity)" Condition="'%(_ResolvedSymbols.Extension)' == '.mdb'" />
        <_ResolvedSymbols Remove="@(_Temp)"/>
    </ItemGroup>
</Target>

This now worked for me. Thank you very much.

@dellis1972 Sure shall share when I run again. for now I unchecked the fast deployment and continue working for now.

I reverted to Visual Studio 16.8.6 and re installed some Android SDK packages and it appears to be working. I was running Visual Studio 16.9.1 previously.

I have same issue as @dan-SLT

had the same problems - problems were solved with updating to Visual Studio version 16.9.2 - no need for workarounds/adaptions of csproj anymore.

Was this page helpful?
0 / 5 - 0 ratings