4,166 questions
Issues in release mode after upgrading to MAUI 9
Manickam, Suraj
320
Reputation points
- After i upgrade from MAUI 8 to MAUI 9 , i face the following issues ,
- I cannot have my target framework to net9.0-android35.0 but i could only use net9.0-android , i get the error as mentioned in the github link https://github.com/dotnet/maui/issues/27057
- this was my configuration for release mode earlier for MAUI 8,
After upgrading to MAUI 9 , DebugType had to be changed to portable and AndroidLinkMode has to be set to false since it trims the class of nuget packages that i added and it throws class not found exception.<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net9.0-android|AnyCPU'"> <AndroidPackageFormat>apk</AndroidPackageFormat> <WarningLevel>1</WarningLevel> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode> <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> <DebugSymbols>False</DebugSymbols> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> <JavaMaximumHeapSize>4G</JavaMaximumHeapSize> <Debugger>.Net (Xamarin)</Debugger> <AotAssemblies>false</AotAssemblies> <EnableLLVM>false</EnableLLVM> <BundleAssemblies>false</BundleAssemblies> <AndroidEnableMultiDex>true</AndroidEnableMultiDex> <AndroidSupportedAbis>armeabi-v7a;x86_64;x86;arm64-v8a</AndroidSupportedAbis> <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot> <AndroidLinkTool>r8</AndroidLinkTool> <RunAOTCompilation>False</RunAOTCompilation> </PropertyGroup>
- I used to load my style class based on condition like this in my app.xaml.cs constructor and this never gets loaded and the default ones gets added. This was working fine in MAUI 8
try { var assembly = typeof(App).Assembly; // Debugging: Check available resources foreach (var res in assembly.GetManifestResourceNames()) { System.Diagnostics.Debug.WriteLine($" Found resource: {res}"); } var colorsDictionary = new ResourceDictionary(); var stylesDictionary = new ResourceDictionary(); // Load Colors.xaml var colorsResourcePath = "AppName.Resources.Styles.Colors.xaml"; using (var stream = assembly.GetManifestResourceStream(colorsResourcePath)) { if (stream == null) throw new Exception($" Resource not found: {colorsResourcePath}"); colorsDictionary.Source = new Uri(colorsResourcePath, UriKind.Relative); } var stylesResourcePath = "AppName.Resources.Styles.Styles_Test.xaml"; using (var stream = assembly.GetManifestResourceStream(stylesResourcePath)) { if (stream == null) throw new Exception($" Resource not found: {stylesResourcePath}"); stylesDictionary.Source = new Uri(stylesResourcePath, UriKind.Relative); } // Ensure Resources exists if (Resources == null) { System.Diagnostics.Debug.WriteLine(" Resources is null. Creating a new ResourceDictionary."); Resources = new ResourceDictionary(); } // Add to MergedDictionaries System.Diagnostics.Debug.WriteLine($" Applying Resource Dictionaries..."); Resources.MergedDictionaries.Clear(); // Optional, only if necessary Resources.MergedDictionaries.Add(colorsDictionary); Resources.MergedDictionaries.Add(stylesDictionary); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($" Error loading resource dictionaries: {ex.Message}\n{ex.StackTrace}"); if (Application.Current?.MainPage != null) { MainThread.BeginInvokeOnMainThread(async () => { await Application.Current.MainPage.DisplayAlert("Error", $"Failed to load styles: {ex.Message}", "OK"); }); } }
Developer technologies | .NET | .NET MAUI
Sign in to answer