[regression/8.0.3] The Android app crashes when you click the back button on the second navigation page after publishing apkย #95973
Open
Description
Description
The Android app crashes when you click the back button on the second navigation page after publishing apk. In debug mode back navigation works as expected. The error appeared after updating .NET MAUI from .net7 to 8.
The error can be reproduced in a newly created project.
My publish settings:
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>partial</TrimMode>
<EnableLLVM>True</EnableLLVM>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidLinkTool>r8</AndroidLinkTool>
<RunAOTCompilation>true</RunAOTCompilation>
<AndroidStripILAfterAOT>false</AndroidStripILAfterAOT>
<AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
<AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
</PropertyGroup>
Steps to Reproduce
- Create a new .NET MAUI App
- Implement navigation using NavigationPage as MainPage in App.xaml.cs instead of Shell
- Create the second page to navigate to
- On Main page create button that navigates to Second page
- Run in Debug mode. Pressing back button on Second page works
- Publish app. Pressing back button on Second page causes app crash
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
7.0.101
Affected platforms
Android
Affected platform versions
Android 8.1
Did you find any workaround?
No response
Relevant log output
[ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalArgumentException: No destination with ID 5 is on the NavController's back stack. The current destination is FragmentNavigator$Destination(0x1) class=crc6452ffdc5b34af3a0f.NavigationViewFragment
at Java.Interop.JniEnvironment.InstanceMethods.CallObjectMethod(JniObjectReference , JniMethodInfo , JniArgumentValue* )
at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualObjectMethod(String , IJavaPeerable , JniArgumentValue* )
at AndroidX.Navigation.NavController.GetBackStackEntry(Int32 )
--- End of managed Java.Lang.IllegalArgumentException stack trace ---
java.lang.IllegalArgumentException: No destination with ID 5 is on the NavController's back stack. The current destination is FragmentNavigator$Destination(0x1) class=crc6452ffdc5b34af3a0f.NavigationViewFragment
at androidx.navigation.NavController.getBackStackEntry(NavController.kt:2411)
at crc6488302ad6e9e4df1a.MauiAppCompatActivity.n_onBackPressed(Native Method)
at crc6488302ad6e9e4df1a.MauiAppCompatActivity.onBackPressed(MauiAppCompatActivity.java:73)
at android.app.Activity.onKeyUp(Activity.java:3031)
at android.view.KeyEvent.dispatch(KeyEvent.java:2734)
at androidx.core.view.KeyEventDispatcher.activitySuperDispatchKeyEventPre28(KeyEventDispatcher.java:143)
at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:89)
at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.java:144)
at androidx.appcompat.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:604)
at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:60)
at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:3413)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:355)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4901)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4773)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4309)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4362)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4328)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4455)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4336)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4512)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4309)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4362)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4328)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4336)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4309)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4362)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4328)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4488)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4655)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2435)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1998)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1989)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2412)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6548)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:43
Metadata
Assignees
Type
Projects
Status
No status