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

XamlC: Maui android Release apk crash in .NET7 #18659

Open
davidchieregato opened this issue Nov 9, 2023 · 11 comments
Open

XamlC: Maui android Release apk crash in .NET7 #18659

davidchieregato opened this issue Nov 9, 2023 · 11 comments
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/android 🤖 t/bug Something isn't working
Milestone

Comments

@davidchieregato
Copy link

Description

The application works fine in debug mode, but when in Release the application crash.

The issue seems to be caused by indexed bindings in xaml

<Label Text="{Binding DayNames[0]}" />
<Label Text="{Binding DayNames[1]}" />

Click Go to days button for crash in Release mode, working fine in Debug.

Steps to Reproduce

Add any indexed string array binding in xaml?

Link to public reproduction project repository

https://github.com/davidchieregato/ReleaseCrash

Version with bug

7.0.101

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

[CompatibilityChangeReporter] Compat change id reported: 171979766; UID 10173; state: ENABLED
[nativeloader] Configuring classloader-namespace for other apk /system_ext/framework/androidx.window.extensions.jar. target_sdk_version=33, uses_libraries=ALL, library_path=/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/lib/arm64:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/base.apk!/lib/arm64-v8a:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.en.apk!/lib/arm64-v8a:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.xxhdpi.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.companyname.releasecrash
[nativeloader] Configuring classloader-namespace for other apk /system_ext/framework/androidx.window.sidecar.jar. target_sdk_version=33, uses_libraries=ALL, library_path=/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/lib/arm64:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/base.apk!/lib/arm64-v8a:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.en.apk!/lib/arm64-v8a:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.xxhdpi.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.companyname.releasecrash
[ziparchive] Unable to open '/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.arm64_v8a.dm': No such file or directory
[ziparchive] Unable to open '/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.arm64_v8a.dm': No such file or directory
[me.releasecrash] Entry not found
[ziparchive] Unable to open '/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.en.dm': No such file or directory
[ziparchive] Unable to open '/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.en.dm': No such file or directory
[me.releasecrash] Entry not found
[ziparchive] Unable to open '/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.xxhdpi.dm': No such file or directory
[ziparchive] Unable to open '/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.xxhdpi.dm': No such file or directory
[me.releasecrash] Entry not found
[nativeloader] Configuring classloader-namespace for other apk /data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/base.apk:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.arm64_v8a.apk:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.en.apk:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.xxhdpi.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/lib/arm64:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/base.apk!/lib/arm64-v8a:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a:/data/app/~~So0ZQeGgsz6yDnz7l88tLw==/com.companyname.releasecrash-7LPmOSAyy2D1RnF_sBuUdQ==/split_config.en.apk!/lib/arm64-v8a:/d
[me.releasecrash] JIT profile information will not be recorded: profile file does not exist.
[me.releasecrash] JIT profile information will not be recorded: profile file does not exist.
[me.releasecrash] JIT profile information will not be recorded: profile file does not exist.
[GraphicsEnvironment] ANGLE Developer option for 'com.companyname.releasecrash' set to: 'default'
[GraphicsEnvironment] ANGLE GameManagerService for com.companyname.releasecrash: false
[GraphicsEnvironment] Neither updatable production driver nor prerelease driver is supported.
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[DOTNET] JNI_OnLoad: JNI_OnLoad in pal_jni.c
[DOTNET] GetOptionalClassGRef: optional class com/android/org/conscrypt/OpenSSLEngineImpl was not found
[monodroid-gc] GREF GC Threshold: 46080
[libEGL] loaded /vendor/lib64/egl/libEGL_emulation.so
[libEGL] loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so
[libEGL] loaded /vendor/lib64/egl/libGLESv2_emulation.so
[CompatibilityChangeReporter] Compat change id reported: 171228096; UID 10173; state: ENABLED
[TabLayout] MODE_SCROLLABLE + GRAVITY_FILL is not supported, GRAVITY_START will be used instead
[CompatibilityChangeReporter] Compat change id reported: 210923482; UID 10173; state: ENABLED
[HostConnection] createUnique: call
[HostConnection] HostConnection::get() New Host Connection established 0xb40000733e8f8790, tid 18078
[HostConnection] HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_vulkan_async_qsri ANDROID_EMU_read_color_buffer_dma ANDROID_EMU_hwc_multi_configs GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0 
[OpenGLRenderer] Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
[OpenGLRenderer] Failed to initialize 101010-2 format, error = EGL_SUCCESS
[EGL_emulation] eglCreateContext: 0xb40000733e8fb790: maj 3 min 0 rcv 3
[EGL_emulation] eglMakeCurrent: 0xb40000733e8fb790: ver 3 0 (tinfo 0x75556a7080) (first time)
[Gralloc4] mapper 4.x is not supported
[HostConnection] createUnique: call
[HostConnection] HostConnection::get() New Host Connection established 0xb40000733e8fbe50, tid 18078
[Gralloc4] allocator 4.x is not supported
[HostConnection] HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_vulkan_async_qsri ANDROID_EMU_read_color_buffer_dma ANDROID_EMU_hwc_multi_configs GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0 
[Parcel] Expecting binder but got null!
[EGL_emulation] app_time_stats: avg=146.24ms min=0.94ms max=1427.23ms count=10
[EGL_emulation] app_time_stats: avg=5907.30ms min=9.51ms max=100164.80ms count=17
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.companyname.releasecrash, PID: 18053
[AndroidRuntime] android.runtime.JavaProxyThrowable: System.Reflection.TargetInvocationException: Arg_TargetInvocationException
[AndroidRuntime]  ---> System.MissingMethodException: Method not found: char System.String[].get_Chars(int) Due to: Failed to load due to unknown reasons
[AndroidRuntime]    at Microsoft.Maui.Controls.Internals.TypedBinding`2[[ReleaseCrash.TestViewModel, ReleaseCrash, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Char, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget)
[AndroidRuntime]    at Microsoft.Maui.Controls.Internals.TypedBinding`2[[ReleaseCrash.TestViewModel, ReleaseCrash, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Char, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Apply(Object context, BindableObject bindObj, BindableProperty targetProperty, Boolean fromBindingContextChanged)
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObject.ApplyBindings(Boolean skipBindingContext, Boolean fromBindingContextChanged)
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObject.SetInheritedBindingContext(BindableObject bindable, Object value)
[AndroidRuntime]    at Microsoft.Maui.Controls.Element.SetChildInheritedBindingContext(Element child, Object context)
[AndroidRuntime]    at Microsoft.Maui.Controls.Element.<OnBindingContextChanged>b__82_0(BindableObject child, Object bc)
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObjectExtensions.PropagateBindingContext[Element](BindableObject self, IEnumerable`1 children, Action`2 setChildBindingContext)
[AndroidRuntime]    at Microsoft.Maui.Controls.Element.OnBindingContextChanged()
[AndroidRuntime]    at Microsoft.Maui.Controls.VisualElement.OnBindingContextChanged()
[AndroidRuntime]    at Microsoft.Maui.Controls.View.OnBindingContextChanged()
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObject.SetInheritedBindingContext(BindableObject bindable, Object value)
[AndroidRuntime]    at Microsoft.Maui.Controls.Element.SetChildInheritedBindingContext(Element child, Object context)
[AndroidRuntime]    at Microsoft.Maui.Controls.TemplatedPage.SetChildInheritedBindingContext(Element child, Object context)
[AndroidRuntime]    at Microsoft.Maui.Controls.Element.<OnBindingContextChanged>b__82_0(BindableObject child, Object bc)
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObjectExtensions.PropagateBindingContext[Element](BindableObject self, IEnumerable`1 children, Action`2 setChildBindingContext)
[AndroidRuntime]    at Microsoft.Maui.Controls.Element.OnBindingContextChanged()
[AndroidRuntime]    at Microsoft.Maui.Controls.VisualElement.OnBindingContextChanged()
[AndroidRuntime]    at Microsoft.Maui.Controls.Page.OnBindingContextChanged()
[AndroidRuntime]    at Microsoft.Maui.Controls.ContentPage.OnBindingContextChanged()
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObject.BindingContextPropertyChanged(BindableObject bindable, Object oldvalue, Object newvalue)
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess)
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value)
[AndroidRuntime]    at Microsoft.Maui.Controls.BindableObject.set_BindingContext(Object value)
[AndroidRuntime]    at ReleaseCrash.DayNames..ctor()
[AndroidRuntime]    at System.Reflection.ConstructorInvoker.InterpretedInvoke(Object , Span`1 , BindingFlags )
[AndroidRuntime]    Exception_EndOfInnerExceptionStack
[AndroidRuntime]    at System.RuntimeType.CreateInstanceMono(Boolean , Boolean )
[AndroidRuntime]    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean , Boolean )
[AndroidRuntime]    at System.Activator.CreateInstance(Type , Boolean , Boolean )
[AndroidRuntime]    at System.Activator.CreateInstance(Type , Boolean )
[AndroidRuntime]    at System.Activator.CreateInstance(Type )
[AndroidRuntime]    at Microsoft.Maui.Controls.Routing.TypeRouteFactory.GetOrCreate(IServiceProvider services)
[AndroidRuntime]    at Microsoft.Maui.Controls.Routing.GetOrCreateContent(String route, IServiceProvider services)
[AndroidRuntime]    at Microsoft.Maui.Controls.ShellSection.GetOrCreateFromRoute(String route, ShellRouteParameters queryData, IServiceProvider services, Boolean isLast, Boolean isPopping)
[AndroidRuntime]    at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable`1 animate, Boolean isRelativePopping)
[AndroidRuntime]    at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest)
[AndroidRuntime]    at ReleaseCrash.MainPage.OnCounterClicked(Object sender, EventArgs e)
[AndroidRuntime]    at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object )
[AndroidRuntime]    at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0()
[AndroidRuntime]    at Java.Lang.Thread.RunnableImplementor.Run()
[AndroidRuntime]    at Java.Lang.IRunnableInvoker.n_Run(IntPtr , IntPtr )
[AndroidRuntime]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V , IntPtr , IntPtr )
[AndroidRuntime] 	at mono.java.lang.RunnableImplementor.n_run(Native Method)
[AndroidRuntime] 	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31)
[AndroidRuntime] 	at android.os.Handler.handleCallback(Handler.java:942)
[AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[AndroidRuntime] 	at android.os.Looper.loopOnce(Looper.java:201)
[AndroidRuntime] 	at android.os.Looper.loop(Looper.java:288)
[AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:7872)
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
[monodroid-assembly] Shared library 'liblog' not loaded, p/invoke '__android_log_print' may fail
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Android.Runtime.JavaProxyThrowable: Exception_WasThrown, Android.Runtime.JavaProxyThrowable
[MonoDroid] 
[MonoDroid]   --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---
[MonoDroid] android.runtime.JavaProxyThrowable: System.Reflection.TargetInvocationException: Arg_TargetInvocationException
[MonoDroid]  ---> System.MissingMethodException: Method not found: char System.String[].get_Chars(int) Due to: Failed to load due to unknown reasons
[MonoDroid]    at Microsoft.Maui.Controls.Internals.TypedBinding`2[[ReleaseCrash.TestViewModel, ReleaseCrash, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Char, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget)
[MonoDroid]    at Microsoft.Maui.Controls.Internals.TypedBinding`2[[ReleaseCrash.TestViewModel, ReleaseCrash, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Char, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Apply(Object context, BindableObject bindObj, BindableProperty targetProperty, Boolean fromBindingContextChanged)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.ApplyBindings(Boolean skipBindingContext, Boolean fromBindingContextChanged)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetInheritedBindingContext(BindableObject bindable, Object value)
[MonoDroid]    at Microsoft.Maui.Controls.Element.SetChildInheritedBindingContext(Element child, Object context)
[MonoDroid]    at Microsoft.Maui.Controls.Element.<OnBindingContextChanged>b__82_0(BindableObject child, Object bc)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObjectExtensions.PropagateBindingContext[Element](BindableObject self, IEnumerable`1 children, Action`2 setChildBindingContext)
[MonoDroid]    at Microsoft.Maui.Controls.Element.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.VisualElement.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.View.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetInheritedBindingContext(BindableObject bindable, Object value)
[MonoDroid]    at Microsoft.Maui.Controls.Element.SetChildInheritedBindingContext(Element child, Object context)
[MonoDroid]    at Microsoft.Maui.Controls.TemplatedPage.SetChildInheritedBindingContext(Element child, Object context)
[MonoDroid]    at Microsoft.Maui.Controls.Element.<OnBindingContextChanged>b__82_0(BindableObject child, Object bc)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObjectExtensions.PropagateBindingContext[Element](BindableObject self, IEnumerable`1 children, Action`2 setChildBindingContext)
[MonoDroid]    at Microsoft.Maui.Controls.Element.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.VisualElement.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.Page.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.ContentPage.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.BindingContextPropertyChanged(BindableObject bindable, Object oldvalue, Object newvalue)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.set_BindingContext(Object value)
[MonoDroid]    at ReleaseCrash.DayNames..ctor()
[MonoDroid]    at System.Reflection.ConstructorInvoker.InterpretedInvoke(Object , Span`1 , BindingFlags )
[MonoDroid]    Exception_EndOfInnerExceptionStack
[MonoDroid]    at System.RuntimeType.CreateInstanceMono(Boolean , Boolean )
[MonoDroid]    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean , Boolean )
[MonoDroid]    at System.Activator.CreateInstance(Type , Boolean , Boolean )
[MonoDroid]    at System.Activator.CreateInstance(Type , Boolean )
[MonoDroid]    at System.Activator.CreateInstance(Type )
[MonoDroid]    at Microsoft.Maui.Controls.Routing.TypeRouteFactory.GetOrCreate(IServiceProvider services)
[MonoDroid]    at Microsoft.Maui.Controls.Routing.GetOrCreateContent(String route, IServiceProvider services)
[MonoDroid]    at Microsoft.Maui.Controls.ShellSection.GetOrCreateFromRoute(String route, ShellRouteParameters queryData, IServiceProvider services, Boolean isLast, Boolean isPopping)
[MonoDroid]    at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable`1 animate, Boolean isRelativePopping)
[MonoDroid]    at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest)
[MonoDroid]    at ReleaseCrash.MainPage.OnCounterClicked(Object sender, EventArgs e)
[MonoDroid]    at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object )
[MonoDroid]    at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0()
[MonoDroid]    at Java.Lang.Thread.RunnableImplementor.Run()
[MonoDroid]    at Java.Lang.IRunnableInvoker.n_Run(IntPtr , IntPtr )
[MonoDroid]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V , IntPtr , IntPtr )
[MonoDroid] 	at mono.java.lang.RunnableImplementor.n_run(Native Method)
[MonoDroid] 	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31)
[MonoDroid] 	at android.os.Handler.handleCallback(Handler.java:942)
[MonoDroid] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[MonoDroid] 	at android.os.Looper.loopOnce(Looper.java:201)
[MonoDroid] 	at android.os.Looper.loop(Looper.java:288)
[MonoDroid] 	at android.app.ActivityThread.main(ActivityThread.java:7872)
[MonoDroid] 	at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
[MonoDroid] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
[MonoDroid] 
[MonoDroid]   --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---
[MonoDroid] android.runtime.JavaProxyThrowable: System.Reflection.TargetInvocationException: Arg_TargetInvocationException
[MonoDroid]  ---> System.MissingMethodException: Method not found: char System.String[].get_Chars(int) Due to: Failed to load due to unknown reasons
[MonoDroid]    at Microsoft.Maui.Controls.Internals.TypedBinding`2[[ReleaseCrash.TestViewModel, ReleaseCrash, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Char, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget)
[MonoDroid]    at Microsoft.Maui.Controls.Internals.TypedBinding`2[[ReleaseCrash.TestViewModel, ReleaseCrash, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Char, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Apply(Object context, BindableObject bindObj, BindableProperty targetProperty, Boolean fromBindingContextChanged)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.ApplyBindings(Boolean skipBindingContext, Boolean fromBindingContextChanged)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetInheritedBindingContext(BindableObject bindable, Object value)
[MonoDroid]    at Microsoft.Maui.Controls.Element.SetChildInheritedBindingContext(Element child, Object context)
[MonoDroid]    at Microsoft.Maui.Controls.Element.<OnBindingContextChanged>b__82_0(BindableObject child, Object bc)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObjectExtensions.PropagateBindingContext[Element](BindableObject self, IEnumerable`1 children, Action`2 setChildBindingContext)
[MonoDroid]    at Microsoft.Maui.Controls.Element.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.VisualElement.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.View.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetInheritedBindingContext(BindableObject bindable, Object value)
[MonoDroid]    at Microsoft.Maui.Controls.Element.SetChildInheritedBindingContext(Element child, Object context)
[MonoDroid]    at Microsoft.Maui.Controls.TemplatedPage.SetChildInheritedBindingContext(Element child, Object context)
[MonoDroid]    at Microsoft.Maui.Controls.Element.<OnBindingContextChanged>b__82_0(BindableObject child, Object bc)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObjectExtensions.PropagateBindingContext[Element](BindableObject self, IEnumerable`1 children, Action`2 setChildBindingContext)
[MonoDroid]    at Microsoft.Maui.Controls.Element.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.VisualElement.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.Page.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.ContentPage.OnBindingContextChanged()
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.BindingContextPropertyChanged(BindableObject bindable, Object oldvalue, Object newvalue)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value)
[MonoDroid]    at Microsoft.Maui.Controls.BindableObject.set_BindingContext(Object value)
[MonoDroid]    at ReleaseCrash.DayNames..ctor()
[MonoDroid]    at System.Reflection.ConstructorInvoker.InterpretedInvoke(Object , Span`1 , BindingFlags )
[MonoDroid]    Exception_EndOfInnerExceptionStack
[MonoDroid]    at System.RuntimeType.CreateInstanceMono(Boolean , Boolean )
[MonoDroid]    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean , Boolean )
[MonoDroid]    at System.Activator.CreateInstance(Type , Boolean , Boolean )
[MonoDroid]    at System.Activator.CreateInstance(Type , Boolean )
[MonoDroid]    at System.Activator.CreateInstance(Type )
[MonoDroid]    at Microsoft.Maui.Controls.Routing.TypeRouteFactory.GetOrCreate(IServiceProvider services)
[MonoDroid]    at Microsoft.Maui.Controls.Routing.GetOrCreateContent(String route, IServiceProvider services)
[MonoDroid]    at Microsoft.Maui.Controls.ShellSection.GetOrCreateFromRoute(String route, ShellRouteParameters queryData, IServiceProvider services, Boolean isLast, Boolean isPopping)
[MonoDroid]    at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable`1 animate, Boolean isRelativePopping)
[MonoDroid]    at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest)
[MonoDroid]    at ReleaseCrash.MainPage.OnCounterClicked(Object sender, EventArgs e)
[MonoDroid]    at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object )
[MonoDroid]    at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0()
[MonoDroid]    at Java.Lang.Thread.RunnableImplementor.Run()
[MonoDroid]    at Java.Lang.IRunnableInvoker.n_Run(IntPtr , IntPtr )
[MonoDroid]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V , IntPtr , IntPtr )
[MonoDroid] 	at mono.java.lang.RunnableImplementor.n_run(Native Method)
[MonoDroid] 	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31)
[MonoDroid] 	at android.os.Handler.handleCallback(Handler.java:942)
[MonoDroid] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[MonoDroid] 	at android.os.Looper.loopOnce(Looper.java:201)
[MonoDroid] 	at android.os.Looper.loop(Looper.java:288)
[MonoDroid] 	at android.app.ActivityThread.main(ActivityThread.java:7872)
[MonoDroid] 	at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
[MonoDroid] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
[MonoDroid] 
[Process] Sending signal. PID: 18053 SIG: 9
@davidchieregato davidchieregato added the t/bug Something isn't working label Nov 9, 2023
@PureWeen
Copy link
Member

@jonathanpeppers thoughts?

@PureWeen PureWeen added the partner/android Issues for the Android SDK label Nov 10, 2023
@PureWeen PureWeen added this to the Backlog milestone Nov 10, 2023
@ghost
Copy link

ghost commented Nov 10, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@jonathanpeppers
Copy link
Member

The problem here likely won't be addressed until this one is complete:

For now, you should be able to use the trimmer settings to preserve:

System.MissingMethodException: Method not found: char System.String[].get_Chars(int)

Maybe something like this:

<linker>
  <assembly fullname="System.Private.CoreLib">
    <type fullname="System.Char" preserve="methods" /> 
    <type fullname="System.String" preserve="methods" /> 
  </assembly>
</linker>

@jonathanpeppers jonathanpeppers changed the title Maui android Release apk crash in .NET7 Trimmer: Maui android Release apk crash in .NET7 Nov 10, 2023
@davidchieregato
Copy link
Author

I just tried to add

<ItemGroup>
	  <TrimmerRootDescriptor Include="TrimmerRoots.xml" />
</ItemGroup>

to the .csproj file with the following content in TrimmerRoots.xml

<?xml version="1.0" encoding="UTF-8" ?>

<linker>
  <assembly fullname="System.Private.CoreLib">
    <type fullname="System.Char" preserve="methods" /> 
    <type fullname="System.String" preserve="methods" /> 
  </assembly>
</linker>

But the error is the same System.MissingMethodException: Method not found: char System.String[].get_Chars(int) Due to: Failed to load due to unknown reasons

Not sure if what I did is the correct way to setup the linker. As Linker Behaviour I have "Link SDK assemblies only"

@jonathanpeppers
Copy link
Member

"Link SDK assemblies only" - yes, System.Private.CoreLib is part of the BCL, a trimmed assembly by default.

If you're not able to setup a precise trimmer rule to fix it, you could try something more heavy-handed:

<ItemGroup>
  <TrimmerRootAssembly Include="System.Private.CoreLib" />
</ItemGroup>

This would just leave this one assembly alone -- leaving it untrimmed.

@davidchieregato
Copy link
Author

davidchieregato commented Nov 10, 2023

Also this last attempt didn't solve the issue. Same error. I am using Visual Studio Mac 17.6.6 (build 408) if it helps.

@jonathanpeppers
Copy link
Member

The stack trace is inside MAUI's TypedBinding. Does the problem go away if you use a regular binding?

The other thing to try is to disable trimming: PublishTrimmed=false.

@davidchieregato
Copy link
Author

Also with trimming disabled the app will crash

<PublishTrimmed>false</PublishTrimmed>
<RunAOTCompilation>false</RunAOTCompilation>

A regular binding would mean to replace the following from the ViewModel

[ObservableProperty]
private string[] _dayNames;

With the following not in the ViewModel but in the .cs file?

public static readonly BindableProperty MyDayNamesProperty =
            BindableProperty.Create(nameof(DayNames), typeof(string[]), typeof(DayNames), default(string[]));

    public string[] MyDayNames
    {
        get => (string[])GetValue(MyDayNamesProperty);
        set => SetValue(MyDayNamesProperty, value);
    }
    public DayNames()
	{
		InitializeComponent();
        MyDayNames = CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedDayNames;
        BindingContext = this;
	}

The result is the same with the same error

@jonathanpeppers
Copy link
Member

I thought removing usage of x:DataType is what would turn off TypedBinding:

https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/data-binding/compiled-bindings

So maybe the issue is not trimming, but XamlC?

https://learn.microsoft.com/en-us/dotnet/maui/xaml/xamlc

What happens if you put [XamlCompilation (XamlCompilationOptions.Skip)] on the one page that is crashing?

@davidchieregato
Copy link
Author

Allright, removing x:DataType it works! And also with with [XamlCompilation (XamlCompilationOptions.Skip)] it works perfectly! So it seems the the issue is related to XamlC

@jonathanpeppers jonathanpeppers added the area-xaml XAML, CSS, Triggers, Behaviors label Nov 10, 2023
@jonathanpeppers jonathanpeppers changed the title Trimmer: Maui android Release apk crash in .NET7 XamlC: Maui android Release apk crash in .NET7 Nov 10, 2023
@gtidev1
Copy link

gtidev1 commented Dec 4, 2023

In my issue (below) I did not change trimming or try [XamlCompilation (XamlCompilationOptions.Skip)] but I noticed today above stack trace ... which maybe be related to:

#19165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants