maui icon indicating copy to clipboard operation
maui copied to clipboard

Crash on release build on Android (App ported from Xamarin) when App.xaml contains GridLength

Open DigitalNut opened this issue 1 year ago • 3 comments

Description

Ported Xamarin app to Maui, works under debug, but crashes when running under Release. Crash is when GridLength is in App.xaml.

The device log reports: System.InvalidProgramException: Invalid IL code in MauiApp3RelaseCrash.App:InitializeComponent (): IL_000e: stloc.2

Visual Studio 17.7.4

Steps to Reproduce

  1. Create a new .NET Maui App (I used .Net 7.0)
  2. Add the following line to App.xaml under <ResourceDictionary> <GridLength x:Key="HeaderHeight">50</GridLength>
  3. Build under debug to verify it runs
  4. Build app under release mode
  5. Run on Android device

Version with bug

7.0.92

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 13

Did you find any workaround?

Yes, remove or comment out GridLength used in App.xaml

Relevant log output

Time	Device Name	Type	PID	Tag	Message
10-06 14:20:29.055	Google Pixel 6a	Info	24845	MonoDroid	
  Force finishing activity com.companyname.mauiapp3relasecrash/crc644ff94c5c9ae9a4f5.MainActivity
10-06 14:20:29.055	Google Pixel 6a	Info	24845	MonoDroid	
   at MauiApp3RelaseCrash.App..ctor()
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags , Binder , Object[] , CultureInfo )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type )
   at System.Collections.Concurrent.ConcurrentDictionary`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Func`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(Type , Func`2 )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type , ServiceProviderEngineScope )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type )
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider , Type )
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[IApplication](IServiceProvider )
   at Microsoft.Maui.MauiApplication.OnCreate()
   at Android.App.Application.n_OnCreate(IntPtr , IntPtr )
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V , IntPtr , IntPtr )
	at crc6488302ad6e9e4df1a.MauiApplication.n_onCreate(Native Method)
	at crc6488302ad6e9e4df1a.MauiApplication.onCreate(MauiApplication.java:28)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1277)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6805)
	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7918)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
10-06 14:20:29.055	Google Pixel 6a	Info	24845	MonoDroid	
10-06 14:20:29.055	Google Pixel 6a	Info	24845	MonoDroid	android.runtime.JavaProxyThrowable: System.InvalidProgramException: Invalid IL code in MauiApp3RelaseCrash.App:InitializeComponent (): IL_000e: stloc.2

DigitalNut avatar Oct 06 '23 21:10 DigitalNut

Hi @DigitalNut. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Oct 09 '23 14:10 ghost

Issue has step to reproduce, still require a repro?

DigitalNut avatar Oct 10 '23 18:10 DigitalNut

Issue is still occuring in latest version 8.01

jkattestaart avatar Jan 26 '24 15:01 jkattestaart

Verified this issue with Visual Studio 17.10.0 Preview 1. Can repro on Android device with above code. App will crash in release mode. image

Zhanglirong-Winnie avatar Mar 01 '24 05:03 Zhanglirong-Winnie