Repository navigation
App crashing when trying to open scanner in release build #207
Copy link
Copy link
Open
Description
Hello,
in the project of my company the app currently crashes when trying to open it.
This only happens when the app is build in the relase configuration but works like a charm in debug.
Do you have any idea how to implement the scanner in a different way to stop this behavior?
This is how its implemented as a popup:
<?xml version="1.0" encoding="utf-8" ?>
<local:BasePage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App.Views.Popups.ScannerPopupPage"
xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI.Controls"
xmlns:local="clr-namespace:App"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:strings="clr-namespace:App.Resources.Strings"
Title="{x:Static strings:AppResources.Scanner}">
<Grid>
<ContentView x:Name="BarcodeReaderContainer"
IsVisible="true">
<zxing:CameraBarcodeReaderView x:Name="CameraBarcodeReader"
BarcodesDetected="BarcodeDetected"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" />
</ContentView>
<BoxView x:Name="UpperGrayedOutSection"
Style="{StaticResource GrayedOutSection}"
VerticalOptions="Start" />
<BoxView x:Name="LowerGrayedOutSection"
Style="{StaticResource GrayedOutSection}"
VerticalOptions="End" />
<BoxView x:Name="redline" IsVisible="true" Style="{StaticResource RedLine}"/>
<Button x:Name="CloseButton" Style="{StaticResource CloseModalButtonStyle}"
Clicked="OnCloseButtonClicked" />
<Button x:Name="FlashlightButton" Style="{StaticResource FlashlightButtonStyle}"
Clicked="OnFlashlightButtonClicked">
<Button.ImageSource>
<FileImageSource File="flashlight.png"></FileImageSource>
</Button.ImageSource>
</Button>
<ImageButton Source="pause_icon"
IsVisible="False"
x:Name="PlayButton"
WidthRequest="100"
Clicked="PlayButton_Clicked" />
<ContentView x:Name="AdditionaleContent"
VerticalOptions="End"
HorizontalOptions="StartAndExpand"
Margin="0,0,0,35" />
<toolkit:MediaElement x:Name="beepPositive"
IsVisible="False"
Source="Resources/Sounds/BeepPositive.wav"/>
<toolkit:MediaElement x:Name="beepNegative"
IsVisible="False"
Source="Resources/Sounds/error-sound.wav"/>
</Grid>
</local:BasePage>
I'll gladly provide additional info if needed.
Best regards,
Hans
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
deko139931 commentedon Jan 21, 2025
I’m facing the same issue. Were you able to resolve it? The app works fine in debugging mode, but when switching to release mode with a distribution certificate and uploading it to TestFlight, it crashes immediately on launch.
olibara commentedon Sep 1, 2025
Same issue today 2025-September-1 with version
ZXing.Net.Xamarin 3.0.0 and
ZXing.Net.Mobile 3.1.0_beta2
Is there Some known fix or turn around ?
jfversluis commentedon Sep 1, 2025
Can you try this: https://blog.verslu.is/maui/exclude-assemblies-from-trimming/ and let me know?
olibara commentedon Sep 1, 2025
olibara commentedon Sep 2, 2025
Hello Gerald
I've tried to disable trimming as mentionned
<PublishTrimmed>false</PublishTrimmed>But it gives an error :
I've also tried to remove another property in the csproj
<TrimMode>full</TrimMode>It also gives an error
Anyway I will try the linker.xml because it is obvious that the issue is coming from the zxing assembly
I will add this
And let you know
olibara commentedon Sep 3, 2025
Hello,
same issue with the Linker explicit directive, in debug it works like a charm but still crash in Release, I will investigate the Logcat details
olibara commentedon Sep 7, 2025
olibara commentedon Sep 7, 2025
The issue was indeed due to the linker 👍
Thanks to Gerald and Jo
This what need to be added in the csproj
olibara commentedon Sep 7, 2025
jfversluis commentedon Sep 12, 2025
We probably should look at how to make the library trimmer safe, but for now this is a good workaround. Thanks for letting us know!
akhilvswoodplc commentedon Dec 3, 2025
@jfversluis
Getting this error while adding the workaround
ILLink : error IL1032: Root assembly 'ZXingNetMobile' could not be found. [{Project}.csproj::TargetFramework=net9.0-ios]