Search code examples
firebasebuildmaui

MAUI & Firebase build errors on Android but debugging works


I spent the last couple of days adding Firebase Push Notifications to my MAUI (net8.0) project. The project only supports iOS and Android. While debugging on physical devices, both iOS and Android, everything works as expected. Now I wan't to build release versions for closed test tracks. On iOS I have no problems generating an ipa file. But when I try to build the Android bundle I get 220 file copy errors. The weird thing is that all of these errors have to do with the nuget package 'xamarin.firebase.ios.cloudfirestore'. Which I think should not be copied at all while building Android?

Below I have added 2 of the errors as an example:

1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\arm64\Microsoft.Common.CurrentVersion.targets(4911,5): error MSB3030: Could not copy the file "C:\Users\mwa\.nuget\packages\xamarin.firebase.ios.cloudfirestore\8.10.0.3\lib\net6.0-ios15.4\Firebase.CloudFirestore.resources\grpc.xcframework\ios-arm64\grpc.framework\PrivateHeaders\src\core\tsi\alts\zero_copy_frame_protector\alts_grpc_record_protocol_common.h" because it was not found.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\arm64\Microsoft.Common.CurrentVersion.targets(4911,5): error MSB3030: Could not copy the file "C:\Users\mwa\.nuget\packages\xamarin.firebase.ios.cloudfirestore\8.10.0.3\lib\net6.0-ios15.4\Firebase.CloudFirestore.resources\grpc.xcframework\ios-arm64_x86_64-simulator\grpc.framework\PrivateHeaders\src\core\ext\filters\client_channel\client_channel_channelz.h" because it was not found.

Does anyone know whats going on here and how to solve this?

I already went through the .csproj file, cleaned the project, deleted the bin and obj folders. Can't seem to find a solution.


Solution

  • The error message indicates that the temporary path is too long. You can go to Environment Variables and change the temp folder to c:\temp or c:\t. Restart your computer after that. The original folder is in C:\Users<username>\AppData\Local\Temp\Xamarin.

    Once you have changed that, in visual studio, go to Package Manager Console to build your project. You can't build using the GUI. You can manually build it in the console.

    dotnet build --framework net8.0-android

    dotnet build --framework net8.0-ios

    After build from console, you can click on Debug. it will skip build.

    For more details, you can refer to the links below:

    https://github.com/dotnet/maui/issues/17828 https://github.com/xamarin/GoogleApisForiOSComponents/issues/555