Closed
Description
Description
I have a class Tür in a .NET 7 class library and I reference this class in a MAUI-App. When compiled in Release with AOT enabled, on an Android device, the app crashes immediatly.
Works on Windows.
Works on Android Emulator
I am using Visual Studio 17.4.5.
Installed Workload Id Manifest Version Installation Source
maui 7.0.59/7.0.100 SDK 7.0.200
Steps to Reproduce
- Create a new .NET MAUI App
- Create a .NET 7 class library
- Add a Reference to the class libarary to the MAUI app
- Add a class Tür to the class library
- Add a field to App.xaml.cs using the class Tür
- Run the app on an android device in Release
Link to public reproduction project repository
https://github.com/CodeAuChocolat/MauiUmlautCrash
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 7, Android 12
Did you find any workaround?
Rename class or disable AOT
Relevant log output
Time Device Name Type PID Tag Message
02-15 10:04:07.288 CipherLab RS31 Error 18286 AndroidRuntime android.runtime.JavaProxyThrowable: System.TypeLoadException: Could not load type of field 'MauiUmlautCrash.App:_tor' (0) due to: Could not resolve type with token 01000058 from typeref (expected class 'UmlautLib.Tür' in assembly 'UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:UmlautLib.Tür member:(null)
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:1024)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5503)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
from settings cache , name = dropbox:data_app_crash , value = null
from settings cache , name = send_action_app_error , value = 1
from settings cache , name = logcat_for_data_app_crash , value = null
Force finishing activity com.companyname.mauiumlautcrash/crc642a249426a1f98bd8.MainActivity
from settings cache , name = dropbox:data_app_crash , value = null
from settings cache , name = dropbox_age_seconds , value = null
from settings cache , name = dropbox_max_files , value = null
from settings cache , name = dropbox_quota_percent , value = null
from settings cache , name = dropbox_reserve_percent , value = null
from settings cache , name = dropbox_quota_kb , value = null