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

Net7.Android - 'SkiaSharp.Views.Android.SKGLSurfaceView': no Java peer type found #686

Closed
DevronB opened this issue Jan 16, 2023 · 2 comments

Comments

@DevronB
Copy link
Contributor

DevronB commented Jan 16, 2023

Android application type

Android for .NET (net7.0-android)

Affected platform version

.Net 7.0.102

Description

I'm using Mapsui in my net6-android project and it's been working fine. I recently upgraded to net7-android. Everything works fine after this update as long as I deploy as Debug. but when I build and deploy a Release version the Mapsui constructor crashes with
System.NotSupportedException: Cannot create instance of type 'SkiaSharp.Views.Android.SKGLSurfaceView': no Java peer type found.

Crash occures on:

var mapControl = new MapControl(Context, null);

Steps to Reproduce

Create new 'Android Application' in VS 17.4.4
Add reference to Mapsui library
construct masui MapControl:

var mapControl = new MapControl(Context, null);

Build and deploy to emulator as Debug - it works
Build and deploy to emulator as Release - it crashes

Did you find any workaround?

no, tried adding SkiaSharp reference but didn't help.

Relevant log output

Error: Unhandled Exception
System.Exception: CurrentDomainOnUnhandledException
 ---> System.NotSupportedException: Cannot create instance of type 'SkiaSharp.Views.Android.SKGLSurfaceView': no Java peer type found.
   at Java.Interop.JniPeerMembers.JniInstanceMethods..ctor(Type )
   at Java.Interop.JniPeerMembers.JniInstanceMethods.GetConstructorsForType(Type )
   at Java.Interop.JniPeerMembers.JniInstanceMethods.StartCreateInstance(String , Type , JniArgumentValue* )
   at Android.Opengl.GLSurfaceView..ctor(Context )
   at SkiaSharp.Views.Android.SKGLSurfaceView..ctor(Context context)
   at Mapsui.UI.Android.MapControl.StartHardwareRenderMode()
   at Mapsui.UI.Android.MapControl.Initialize()
   at Mapsui.UI.Android.MapControl..ctor(Context context, IAttributeSet attrs)
   at GTApp.Android.MapMeasure.OnConfigureDataView()
   at GTApp.Android.MeasureView`1[[Mapsui.UI.Android.MapControl, Mapsui.UI.Android, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null]].BuildDataView()
   at GTApp.Android.MeasureView`1[[Mapsui.UI.Android.MapControl, Mapsui.UI.Android, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null]]..ctor(Context context, MeasureDef measureDef, Activity activity, LayoutViewMode mode)
   at GTApp.Android.MapMeasure..ctor(Context context, MeasureDef measureDef, Activity activity, LayoutViewMode mode)
   at GTApp.Android.MeasureView.GetViewFor(Context context, MeasureDef measureDef, Activity activity, LayoutViewMode mode)
   at GTApp.Android.MeasureView.<>c__DisplayClass100_0.<GetViewsForListOrdered>b__2(Measure m)
   at System.Linq.Enumerable.SelectListIterator`2[[GTCore.Measure, GTCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[GTApp.Android.MeasureView, GTApp.Android, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Collections.Generic.List`1[[GTApp.Android.MeasureView, GTApp.Android, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].InsertRange(Int32 , IEnumerable`1 )
   at System.Collections.Generic.List`1[[GTApp.Android.MeasureView, GTApp.Android, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 )
   at GTApp.Android.MeasureView.GetViewsForListOrdered(Context context, Activity gtActivity)
   at GTApp.Android.MeasureListDialog.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
   at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr , IntPtr , IntPtr , IntPtr , IntPtr )
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L , IntPtr , IntPtr , IntPtr , IntPtr , IntPtr )
   Exception_EndOfInnerExceptionStack
@jpobst
Copy link
Contributor

jpobst commented Jan 17, 2023

I don't think this is the correct repository for this issue.

If you think it's an issue with Mapsui, their repository is here:
https://github.com/Mapsui/Mapsui

If you think it's an issue with SkiaSharp, their repository is here:
https://github.com/mono/SkiaSharp

@jpobst jpobst closed this as completed Jan 17, 2023
@DevronB
Copy link
Contributor Author

DevronB commented Jan 17, 2023

oh ok, I thought it was more to do with the release build as it's working in debug mode?

I'll log an issue in SkiaSharp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants