Jiri Matejka
Jiri Matejka

Reputation: 106

Xamarin.Forms app randomly crashes on Android

am observing an issue with Xamarin.Forms application on Android. Generally it works fine, but randomly it crashes with a message like

crc643f46942d9dd1fff9.PlatformRenderer.onMeasure PlatformRenderer.java, line 63 Java.Lang.IllegalStateException: View with id -1: crc643f46942d9dd1fff9.FlyoutPageRenderer#onMeasure() did not set the measured dimension by calling setMeasuredDimension()

or

androidx.appcompat.widget.ContentFrameLayout.onMeasure ContentFrameLayout.java, line 145 java.lang.IllegalStateException: View with id -1: crc643f46942d9dd1fff9.PlatformRenderer#onMeasure() did not set the measured dimension by calling setMeasuredDimension()

The navigation scheme is master-detail (using FlyoutPage class rather than the obsolete MasterDetailPage class), there are some Syncfusion controls (listview, toggle button), AndroidX packages.

It is impossible to replicate on will, I can see these errors only in application telemetry logs.

Any ideas where such issue may come from?

thanks

Jiri

Upvotes: 0

Views: 205

Answers (1)

Wendy Zang - MSFT
Wendy Zang - MSFT

Reputation: 10938

You could force the call of the setMeasuredDimension inside your onMeasure() method to fix the issue.

 @Override
protected void onMeasure(int widthSpec, int heightSpec) {
    setMeasuredDimension(widthSpec, heightSpec);
    super.onMeasure(widthSpec, heightSpec);
    shortestDistance = getMeasuredWidth() / 3;
}

Upvotes: 0

Related Questions