dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.75k forks source link

Android Release build crashes on device but Debug build runs #19165

Open gtidev1 opened 11 months ago

gtidev1 commented 11 months ago

Description

Unexpected release build crash on Android device (after the same code works on the device as a debug build)

Steps to Reproduce

  1. Create the sample MAUI project (Visual Studio 17.8.2, net8.0) and run the Debug build on an Android device
  2. Add this to MainPage.xaml <Entry Style="{StaticResource MisssingStyle}" Text="Placeholder" />
  3. Rerun the Debug build on the Android device. It executes and shows the new UI element
  4. Switch to Release build and run on the Android device with crash info attached

Link to public reproduction project repository

No response

Version with bug

8.0.3

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

Android 13

Did you find any workaround?

After working for some time (after a typo) running Debug builds, finding the bug takes too long. The Android logcat info is useless. I did not see any useful warning/error info using the default configuration of the developer environment either. Requests: Can the developer environment indicate in the editor window some warning/error for a resource that is a typo / missing Can the build process indicate in the output some warning/error for a resource that is a typo / missing Can the behavior (on device) of the Release build and Debug build be made the same for a resource that is a typo / missing (either both builds work or both builds fail)

Possibly related issues: https://github.com/dotnet/maui/issues/15602 https://github.com/dotnet/maui/issues/8928

Relevant log output

Time    Device Name Type    PID Tag Message
12-01 15:34:52.036  OnePlus LE2115  Warning 1890    OplusEapManager handleErrorInfo sendEvent:  com.companyname.mauiandroidreleasecrash Crashed
12-01 15:34:52.036  OnePlus LE2115  Debug   1890    TheiaManager    sendEvent {0x5 6878579 0x1003 21230 10210 com.companyname.mauiandroidreleasecrash}
12-01 15:34:52.034  OnePlus LE2115  Debug   3803    BufferQueueConsumer [VRI[Launcher]#29(BLAST Consumer)29](id:edb00000040,api:0,p:-1,c:3803) disconnect
12-01 15:34:52.034  OnePlus LE2115  Debug   1890    OplusAppStartupMonitor  notifyUnstableAppInfo: Bundle[{unstableTime=1701466492033, reason=crash, userId=0, exceptionMsg=[System.Reflection.TargetInvocationException]: Arg_TargetInvocationException, exceptionClass=android.runtime.JavaProxyThrowable, app_channel_type=unstable, packageName=com.companyname.mauiandroidreleasecrash, unstable_restrict_switch=true}]
12-01 15:34:52.031  OnePlus LE2115  Verbose 1890    WindowManager   Relayout Window{bc4f5b4 u0 com.android.launcher/com.android.launcher.Launcher}: viewVisibility=8, oldvis=0, req=1080x2400
12-01 15:34:52.030  OnePlus LE2115  Info    21230   MonoDroid   
12-01 15:34:52.030  OnePlus LE2115  Info    21230   MonoDroid   android.runtime.JavaProxyThrowable: [System.Reflection.TargetInvocationException]: Arg_TargetInvocationException
    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Unknown Source:0)
    at System.RuntimeType.CreateInstanceMono(Unknown Source:0)
    at System.RuntimeType.CreateInstanceDefaultCtor(Unknown Source:0)
    at System.Activator.CreateInstance(Unknown Source:0)
    at System.Activator.CreateInstance(Unknown Source:0)
    at System.Activator.CreateInstance(Unknown Source:0)
    at Microsoft.Maui.Controls.ShellContent+<>c__DisplayClass19_0.<Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent>b__0(Unknown Source:0)
    at Microsoft.Maui.Controls.ElementTemplate.CreateContent(Unknown Source:0)
    at Microsoft.Maui.Controls.Internals.DataTemplateExtensions.CreateContent(Unknown Source:0)
    at Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent(Unknown Source:0)
    at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnCreateView(Unknown Source:0)
    at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(Unknown Source:0)
    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(Unknown Source:0)
    at crc640ec207abc449b2ca.ShellSectionRenderer.n_onCreateView(Native Method)
    at crc640ec207abc449b2ca.ShellSectionRenderer.onCreateView(ShellSectionRenderer.java:44)
    at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3114)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:557)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1845)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3042)
    at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2945)
    at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3148)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:588)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1845)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3042)
    at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2952)
    at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:263)
    at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:350)
    at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1529)
    at android.app.Activity.performStart(Activity.java:8447)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3897)
    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2470)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:240)
    at android.os.Looper.loop(Looper.java:351)
    at android.app.ActivityThread.main(ActivityThread.java:8423)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
12-01 15:34:52.030  OnePlus LE2115  Info    21230   MonoDroid   
  --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---
12-01 15:34:52.030  OnePlus LE2115  Info    21230   MonoDroid   android.runtime.JavaProxyThrowable: [System.Reflection.TargetInvocationException]: Arg_TargetInvocationException
    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Unknown Source:0)
    at System.RuntimeType.CreateInstanceMono(Unknown Source:0)
    at System.RuntimeType.CreateInstanceDefaultCtor(Unknown Source:0)
    at System.Activator.CreateInstance(Unknown Source:0)
    at System.Activator.CreateInstance(Unknown Source:0)
    at System.Activator.CreateInstance(Unknown Source:0)
    at Microsoft.Maui.Controls.ShellContent+<>c__DisplayClass19_0.<Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent>b__0(Unknown Source:0)
    at Microsoft.Maui.Controls.ElementTemplate.CreateContent(Unknown Source:0)
    at Microsoft.Maui.Controls.Internals.DataTemplateExtensions.CreateContent(Unknown Source:0)
    at Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent(Unknown Source:0)
    at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnCreateView(Unknown Source:0)
    at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(Unknown Source:0)
    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(Unknown Source:0)
    at crc640ec207abc449b2ca.ShellSectionRenderer.n_onCreateView(Native Method)
    at crc640ec207abc449b2ca.ShellSectionRenderer.onCreateView(ShellSectionRenderer.java:44)
    at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3114)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:557)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1845)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3042)
    at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2945)
    at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3148)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:588)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1845)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3042)
    at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2952)
    at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:263)
    at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:350)
    at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1529)
    at android.app.Activity.performStart(Activity.java:8447)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3897)
    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2470)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:240)
    at android.os.Looper.loop(Looper.java:351)
    at android.app.ActivityThread.main(ActivityThread.java:8423)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
12-01 15:34:52.030  OnePlus LE2115  Info    21230   MonoDroid   
  --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---
12-01 15:34:52.030  OnePlus LE2115  Info    21230   MonoDroid   Android.Runtime.JavaProxyThrowable: Exception_WasThrown, Android.Runtime.JavaProxyThrowable
12-01 15:34:52.029  OnePlus LE2115  Error   1456    SchedAssist ofbSetSfMsgTrans pid(1456) failed with error=Permission denied
12-01 15:34:52.027  OnePlus LE2115  Info    21230   MonoDroid   UNHANDLED EXCEPTION:
12-01 15:34:52.027  OnePlus LE2115  Warning 21230   monodroid-assembly  Shared library 'liblog' not loaded, p/invoke '__android_log_print' may fail
12-01 15:34:52.025  OnePlus LE2115  Error   21230   AndroidRuntime  android.runtime.JavaProxyThrowable: [System.Reflection.TargetInvocationException]: Arg_TargetInvocationException
    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Unknown Source:0)
    at System.RuntimeType.CreateInstanceMono(Unknown Source:0)
    at System.RuntimeType.CreateInstanceDefaultCtor(Unknown Source:0)
    at System.Activator.CreateInstance(Unknown Source:0)
    at System.Activator.CreateInstance(Unknown Source:0)
    at System.Activator.CreateInstance(Unknown Source:0)
    at Microsoft.Maui.Controls.ShellContent+<>c__DisplayClass19_0.<Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent>b__0(Unknown Source:0)
    at Microsoft.Maui.Controls.ElementTemplate.CreateContent(Unknown Source:0)
    at Microsoft.Maui.Controls.Internals.DataTemplateExtensions.CreateContent(Unknown Source:0)
    at Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent(Unknown Source:0)
    at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnCreateView(Unknown Source:0)
    at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(Unknown Source:0)
    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(Unknown Source:0)
    at crc640ec207abc449b2ca.ShellSectionRenderer.n_onCreateView(Native Method)
    at crc640ec207abc449b2ca.ShellSectionRenderer.onCreateView(ShellSectionRenderer.java:44)
    at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3114)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:557)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1845)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3042)
    at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2945)
    at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3148)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:588)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1845)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3042)
    at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2952)
    at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:263)
    at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:350)
    at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1529)
    at android.app.Activity.performStart(Activity.java:8447)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3897)
    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2470)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:240)
    at android.os.Looper.loop(Looper.java:351)
    at android.app.ActivityThread.main(ActivityThread.java:8423)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
12-01 15:34:52.025  OnePlus LE2115  Error   21230   AndroidRuntime  Process: com.companyname.mauiandroidreleasecrash, PID: 21230
12-01 15:34:52.025  OnePlus LE2115  Error   21230   AndroidRuntime  FATAL EXCEPTION: main
12-01 15:34:52.024  OnePlus LE2115  Debug   21230   AndroidRuntime  Shutting down VM
BaY1251 commented 11 months ago

+1

kevinxufei commented 6 months ago

Verified this issue with Visual Studio 17.10.0 Preview 3 (8.0.20 & 8.0.0-rc.2.9530). Can repro this issue on Android device (api33).

TimurVa commented 6 months ago

I'm checking every release made by this repo since prev year. Not a single handles this. Every time I start my app in Debug it works. Switch to Release and getting crush with exact same error. Even Debug build can't start. Only via Visual Studio Debug through USB

bsdRuf commented 5 months ago

same issue here, if any info is helping to find a fix or workaround please have a look. Otherwise it can be closed since this is open already. https://github.com/dotnet/maui/issues/22825