-
Notifications
You must be signed in to change notification settings - Fork 533
Diagnose Fast Deployment Issues
There are numerous situations where fast deployment does not work or gives an error. These normally end up displaying the following error
error XA0129: Error deploying 'files/.__override__/Foo.dll'.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(613,5): error XA0129: Please set the 'EmbedAssembliesIntoApk' MSBuild property to 'true' to disable Fast Deployment in the Visual Studio project property pages, or edit the project file in a text editor.
The general advice is to disable fast deployment by setting EmbedAssembliesIntoApk
to true
. This will allow the
project to debug on the device. It does unblock the user but it does degrade the overally debug experience.
Given the numerous types of android devices out there, and the ability for the manufactures to alter the OS it is difficult to know what causes these issues allot of the time. So if you want to help us diagnose the issue here are a few steps which will help the team get to the bottom of what is causing the problem.
The first step is to try to reproduce the problem from the command line. Open a Developer Command Prompt
for your IDE then
navigate to the location of your Android csproj. Now depending on if you are using dotnet
or Xamarin Classic
will change
how you install the project.
If you are using .NET 6+ for Android you can use the dotnet
command to install your app.
dotnet build foo.csproj -t:Install -p:_FastDeploymentDiagnosticLogging=true -p:EmbedAssembliesIntoApk=false -bl
If you are still using the older style projects (Xamarin Classic) you can use msbuild.
msbuild foo.csproj -t:Install -p:_FastDeploymentDiagnosticLogging=true -p:EmbedAssembliesIntoApk=false -bl
Note we are passing an additional property _FastDeploymentDiagnosticLogging
. This property enables some detailed diagnostic
logging specifically for fast deployment. It is not on by default because it SLOWS down the deployment process.
We are setting -p:EmbedAssembliesIntoApk=false
to make use that fast deployment is turned on.
The -bl
will force dotnet
or msbuild
to produce a msbuild.binlog
file which will contain the logs. This file can be
zipped up and sent to use for analysis.
If you are unable to reproduce the issue on the command line you will need to try to gather the required data from the IDE.
The easiest way to do this is with the Project System Tools. Once installed it gives you access to all of the build logs for
every build and saves then in binlog
format as well. It is much more useful that the typical Diagnostic Text Logging provided
by Visual Studio by default.
Head to the following URL to install the extension Project System Tools 2022.
For details on how to use the extension see HowTo.
First thing to do is to re-enable fast deployment in the IDE by setting EmbedAssembliesIntoApk
to false
in the csproj or
unchecking the appropriate check box in the project properties. This will make sure fast deployment is being used. It is very
easy to forget this step as the error message does tell you to disable it.
In order to get the additional diagnostic data in the IDE we need to set the _FastDeploymentDiagnosticLogging
for the build.
The easiest way is to add the following xml snippet to your csproj.
<PropertyGroup>
<_FastDeploymentDiagnosticLogging>true</_FastDeploymentDiagnosticLogging>
</PropertyGroup>
You can add this anywhere in between the Project
elements in the csproj.
Alternatively if you do not want to edit your csproj you can create a Directory.Build.props
file in the same directory
and paste in the following contents.
<Project>
<PropertyGroup>
<_FastDeploymentDiagnosticLogging>true</_FastDeploymentDiagnosticLogging>
</PropertyGroup>
</Project>
If you already use a Directory.Build.props
you can add the PropertyGroup
contents to that existing file.
Once you have Project System Tools installed and the _FastDeploymentDiagnosticLogging
property set you can start gathering
the diagnostic data. Follow the instructions here to open the Project
System Tools window in Visual Studio. You can then click the "play" button to start logging.
Then deploy your application. The various builds will appear in the list. You are speficially looking for the one which calls the Install
or _Run
targets. Right click and save these logs to a location of your choice. Then zip these up and send them to the team.
Note that the additional logging WILL slow down deployment times and it does produce ALLOT of data. So deployment times will be slower, we do
NOT recommend you leave the _FastDeploymentDiagnosticLogging
on all the time. It is only for gathering data.
- APK Tests on the Hyper V Emulator
- Design Time Build System
- Profile MSBuild Tasks
- Diagnose Fast Deployment Issues
- Preview layout XML files with Android Studio
- Documentation