Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RelativeLayout crashes android app. #12748

Closed
comarkiewicz opened this issue Jan 18, 2023 · 6 comments
Closed

RelativeLayout crashes android app. #12748

comarkiewicz opened this issue Jan 18, 2023 · 6 comments
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-relative platform/android 🤖 s/not-a-bug This isn't actually a bug, or is working as expected s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@comarkiewicz
Copy link

Description

Using a RelativeLayout will result in a .NET MAUI app to crash while on Android. Other platforms haven't been tested. No errors or exceptions are produced in the debugger or the device log.

Steps to Reproduce

  1. Create a new .NET MAUI app.
  2. Replace the contents of the MainPage.xaml with the following:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:cmp="clr-namespace:Microsoft.Maui.Controls.Compatibility;assembly=Microsoft.Maui.Controls"
             x:Class="Test_Maui_App.MainPage">

    <ScrollView>
        <cmp:RelativeLayout>

        </cmp:RelativeLayout>
    </ScrollView>

</ContentPage>
  1. Replace the contents of the MainPage.xaml.cs with the following:
namespace Test_Maui_App;

public partial class MainPage : ContentPage
{
	public MainPage()
	{
		InitializeComponent();
	}
}
  1. Attempt to run the app on an android device and observe the crash that occurs.

Link to public reproduction project repository

https://github.com/comarkiewicz/RelativeLayout-Crash

Version with bug

6.0.312

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12 and up

Did you find any workaround?

No response

Relevant log output

No response

@comarkiewicz comarkiewicz added the t/bug Something isn't working label Jan 18, 2023
@rachelkang rachelkang added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-relative platform/android 🤖 labels Jan 18, 2023
@rachelkang rachelkang added this to the Backlog milestone Jan 18, 2023
@ghost
Copy link

ghost commented Jan 18, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@jfversluis
Copy link
Member

Also seems to (still) happen on Windows: #6063 (comment)

@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jun 16, 2023
@XamlTest
Copy link

Verified this on Visual Studio Enterprise 17.7.0 Preview 2.0. Repro on Windows 11, Android 13.0-API33 and iOS 16.4 with below Project:
12748.zip
image

@samhouts
Copy link
Member

samhouts commented Aug 4, 2023

This is not a bug. The RelativeLayout is a compatibility feature. You must opt into these features by configuring your MauiProgram to Use Compatibility. You do this by editing your MauiProgram.cs to the following:

	public static MauiApp CreateMauiApp()
	{
		var builder = MauiApp.CreateBuilder();
		builder
			.UseMauiApp<App>()
			.ConfigureFonts(fonts =>
			{
				fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
				fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
			})
            .UseMauiCompatibility(); // <---- add this line!!

#if DEBUG
		builder.Logging.AddDebug();
#endif

		return builder.Build();
	}

The error message tells you to do this.

I verified that this works with the repro project.

Thanks!

@samhouts samhouts added the s/not-a-bug This isn't actually a bug, or is working as expected label Aug 4, 2023
@samhouts samhouts closed this as completed Aug 4, 2023
@jaysidri
Copy link

jaysidri commented Aug 17, 2023

The MauiApp builder does not have a method named UseMauiCompatibility() -- do I need to install a nuget to enable this?

EDIT: never mind -- this extension method requires a using Microsoft.Maui.Controls.Compatibility.Hosting;

@ghost
Copy link

ghost commented Aug 17, 2023

Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!

@ghost ghost locked as resolved and limited conversation to collaborators Sep 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-relative platform/android 🤖 s/not-a-bug This isn't actually a bug, or is working as expected s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants