-
Notifications
You must be signed in to change notification settings - Fork 1.9k
System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.SearchBarRenderer from native handle 0x7fe862fc54 (key_handle 0xb1c5ad6). #6550
Comments
This error is related to a problem in the dispose. |
I added a branch with reproduction, seems that when the toolbar is being reset, and when removing the nativeview, this normally is because it was disposed before. Doesn''t happen with a Entry for example. |
@rmarinho Thanks for the repro. What is strange with this case is that dispose is normaly triggered after the page has been popped and not rotated, unless the activity is configured to not handle the orientation change. |
I already made some changes in the NavigationPageRenderer dispose method.
|
I succeed to reproduce it. Here the complete stacktrace. 0x3B in Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.ResetToolbar at D:\Workspace\Xamarin\Xamarin.Forms\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:718,4
0x27 in Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.DeviceInfoPropertyChanged at D:\Workspace\Xamarin\Xamarin.Forms\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:542,5
0x33 in System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start<Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.<DeviceInfoPropertyChanged>d__72>
0x38 in Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.DeviceInfoPropertyChanged
0x13 in Xamarin.Forms.Internals.DeviceInfo.OnPropertyChanged at D:\Workspace\Xamarin\Xamarin.Forms\Xamarin.Forms.Core\DeviceInfo.cs:49,7
0x2A in Xamarin.Forms.Internals.DeviceInfo.set_CurrentOrientation at D:\Workspace\Xamarin\Xamarin.Forms\Xamarin.Forms.Core\DeviceInfo.cs:21,5
0x37 in Xamarin.Forms.Forms.AndroidDeviceInfo.CheckOrientationChanged at D:\Workspace\Xamarin\Xamarin.Forms\Xamarin.Forms.Platform.Android\Forms.cs:377,6
0x8 in Xamarin.Forms.Forms.AndroidDeviceInfo.ConfigurationChanged at D:\Workspace\Xamarin\Xamarin.Forms\Xamarin.Forms.Platform.Android\Forms.cs:386,5
0x1B in Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnConfigurationChanged at D:\Workspace\Xamarin\Xamarin.Forms\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:66,4 As expected, it is the |
I can confirm that the latest modifications included in #6467 fix the issue. @samhouts Do you want a separate PR for this one too ? I also have a question on the UpdateTitleView method ? void UpdateTitleView()
...
if (_titleViewRenderer != null)
{
var reflectableType = _titleViewRenderer as System.Reflection.IReflectableType;
var rendererType = reflectableType != null ? reflectableType.GetTypeInfo().AsType() : _titleViewRenderer.GetType();
if (titleView == null || Registrar.Registered.GetHandlerTypeForObject(titleView) != rendererType)
{
if (_titleView != null)
_titleView.Child = null;
Android.Platform.ClearRenderer(_titleViewRenderer.View);
_titleViewRenderer.Dispose();
_titleViewRenderer = null;
}
}
... I think that this bloc can cause issue too. |
@samhouts we are facing random crash similar to above crash |
@Srikanth540-L Do you have a reproduction project you can share? Thanks! |
I am getting a very similar issue to @Srikanth540-L . Raised a bug #11098 |
@Srikanth540-L did you find any solution for that? i have exactly same exception? |
There is Xamarin form using searchbar control at title view of navigation page. It throws exception on rotation of android device when control is active i.e control has focus and opened keyword to enter text.
Steps to Reproduce
System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.SearchBarRenderer from native handle 0x7fe862fc54 (key_handle 0xb1c5ad6).
Xamarin form 4.1.0.496342-pre2
Android device: Samsung SM-M305F
Android version: 8.1.0
The text was updated successfully, but these errors were encountered: