Table of Contents
Android API level missing
If you see an error like the following, some Android dependencies are missing.
/.../Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Tooling.targets(100,5): error XA5207: Could not find android.jar for API level 34. This means the Android SDK platform for API level 34 is not installed; it was expected to be in `/PATH_TO_SDK/platforms/android-34/android.jar`.
Install the missing dependencies by executing the following commands in a terminal window. Make sure that you are in the project directory. You also need to use the correct path for your Android SDK. The path you need is shown in the error message.
export AcceptAndroidSDKLicenses=true dotnet build -t:InstallAndroidDependencies -f net8.0-android "-p:AndroidSdkDirectory=/PATH_TO_SDK"
Android emulator hangs during startup on Windows
The emulator runs an Android image as a virtual machine. This needs to be enabled in the Windows BIOS.
Crash on start
If your application was previously working but starts to crash on starting up, it may be because some package versions have changed. Try removing all of the object and binary files and recompiling. Right-click on the project in the Solution Explorer and click Clean
During setup, directories are created with percent signs in their names (e.g. %ANDROID_HOME%)
This happens when you use the Windows PowerShell when running a terminal. Use the basic CMD command window instead. You can configure your VSCode profile to use CMD by default
Exception -532462766
When trying to start the Android emulator, this exception is reported accompanied by the additional messages below.
C:\Users\133423866\MAUI>sdkmanager --install "system-images;android-34;google_apis;x86_64" Warning: Errors during XML parse: Warning: Additionally, the fallback loader failed to parse the XML. Warning: Errors during XML parse: Warning: Additionally, the fallback loader failed to parse the XML. [=======================================] 100% Computing updates...
The reason for this error is unknown, but it can be ignored - it should not affect the emulator.
Initial migration fails - unable to create DbContext
The following error message appears when trying to create the initial migration:
Unable to create a 'DbContext' of type 'NotesDbContext'. The exception 'Method 'get_LockReleaseBehavior' in type 'Microsoft.EntityFrameworkCore.SqlServer.Migrations.Internal.SqlServerHistoryRepository' from assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=8.0.7.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
Check the Notes.Migrations
.csproj
file. remove any reference to EntityFramework version 9.*.
For example, if you see the following ItemGroup
, delete the whole thing and try the initial migration again:
<ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.2"> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <PrivateAssets>all</PrivateAssets> </PackageReference> </ItemGroup>
Missing workloads
After certain updates, the .NET workloads associated with a project need to be reinstalled. When this happens, you will see an error like the following:
Determining projects to restore... /.../Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: wasi-experimental [/.../Notes/Notes.csproj::TargetFramework=net8.0-android] /.../Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore [/.../Notes/Notes.csproj::TargetFramework=net8.0-android]
The command shown in the error message may not work if the restoration requires elevated privileges. On Mac or Linux, use the following command at a terminal prompt ensuring that you are in the project directory:
sudo dotnet workload restore
On Windows, start a command shell with administrator privilege, change into the project directory and execute the command:
dotnet workload restore
Package downgrade detected
If you see an error like the following, it means that there is a conflict between different NuGet packages and you need to upgrade one or more of them to their latest version.
Determining projects to restore... All projects are up-to-date for restore. Determining projects to restore... /.../Notes/Notes.csproj : error NU1605: Warning As Error: Detected package downgrade: Microsoft.EntityFrameworkCore from 8.0.7 to 8.0.6. Reference the package directly from the project to select a different version. [/.../Notes.sln]
Look in the Notes.sln
file to find the package that the error message refers to. Then, right-click on the project in the Solution Explorer and reinstall that package choosing the required version when prompted. This will update the references in the project file.
Platform simulator not found
If you see an error like the following when building your code, your project file includes the iOS platform, but you do not have a simulator installed.
/.../Notes/obj/Debug/net8.0-ios/iossimulator-arm64/actool/cloned-assets/Assets.xcassets : actool error : The operation couldn’t be completed. Failed to locate any simulator runtime matching options: { [/.../Notes/Notes.csproj::TargetFramework=net8.0-ios]
The simplest solution is to remove the reference to iOS from the project file. Locate the TargetFrameworks
entry near the start of the file and remove iOS as a target. The example below shows the line before and after the change.
<!-- BEFORE --> <TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks> <!-- AFTER --> <TargetFrameworks>net8.0-android;net8.0-maccatalyst</TargetFrameworks>
If you prefer to install a simulator so that you can keep the iOS target, please refer to the Microsoft documentation.
Request nominateProject failure
When starting VSCode, you may see the error below from time to time. It seems to arise when the host computer is busy and results from a race condition between different startup processes.
LimitedFunctionality StreamJsonRpc.RemoteInvocationException: Request nominateProject failed with message: Cannot read properties of undefined (reading 'size')
The best solution seems to be to restart your computer to kill any unnecessary processes.