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

Switching language on Android results in a crash while navigating if resource manager used (i18n) #6732

Closed
nk54 opened this issue May 2, 2022 · 3 comments · Fixed by #8455
Assignees
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/android 🤖 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@nk54
Copy link

nk54 commented May 2, 2022

Description

Hello,

I have a MAUI app with 2 resources (ResourceManager), one FR, one EN.

It works really well with the package Microsoft.Extensions.Localization : I'm able to load the correct translation based on the user culture. I can navigate between pages, everything works great.

But if I switch the main language in Android's settings, I go back to the app (was in background while I changed the settings), I try to navigate to a new page to see if the translations are fine, it crashes. (I don't expect live changes when changing my language but at least, while navigating to a new page, I expect the correct translations to be found)

Here is the error
Java.Lang.IllegalArgumentException: 'No view found for id 0x1 (unknown) for fragment ShellItemRenderer{dd448d5} (e47cc305-1d52-4c02-9754-e65f4ffa09df id=0x1)'

No callstack, only external code

Steps to Reproduce

Create an app (I use AppShell) with 2 pages.

Add 2 resources to the project and a dependence Microsoft.Extensions.Localization package.
Don't forget to register the dependencie: builder.Services.AddLocalization();
Create a couple of key/values.

Launch the app on Android. See it works.

Go to Android settings, switch from english to the language you added in your 2nd resx.

Go back to the app, try to navigate.

Boom

Couldn't test on Windows as you have to log off to change the language.

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 11

Did you find any workaround?

Not yet

Relevant log output

[enpharma.mobil] Invalid ID 0x00000001.
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.MY_APP_BUNDLEID_WAS_SET_HERE, PID: 29817
[AndroidRuntime] java.lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment ShellItemRenderer{dd448d5} (e47cc305-1d52-4c02-9754-e65f4ffa09df id=0x1)
[AndroidRuntime] 	at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:513)
[AndroidRuntime] 	at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
[AndroidRuntime] 	at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
[AndroidRuntime] 	at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1758)
[AndroidRuntime] 	at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1701)
[AndroidRuntime] 	at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:488)
[AndroidRuntime] 	at android.os.Handler.handleCallback(Handler.java:873)
[AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[AndroidRuntime] 	at android.os.Looper.loop(Looper.java:193)
[AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:6669)
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
**Java.Lang.IllegalArgumentException:** 'No view found for id 0x1 (unknown) for fragment ShellItemRenderer{dd448d5} (e47cc305-1d52-4c02-9754-e65f4ffa09df id=0x1)'
@nk54 nk54 added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels May 2, 2022
@nk54 nk54 changed the title Switching language on Android results in a crash while navigating Switching language on Android results in a crash while navigating if resource manager used May 2, 2022
@nk54 nk54 changed the title Switching language on Android results in a crash while navigating if resource manager used Switching language on Android results in a crash while navigating if resource manager used (i18n) May 2, 2022
@Redth Redth added platform/android 🤖 area-controls-shell Shell Navigation, Routes, Tabs, Flyout labels May 2, 2022
@Redth Redth added this to the 6.0.300-servicing milestone May 2, 2022
@jfversluis jfversluis removed the s/needs-verification Indicates that this issue needs initial verification before further triage will happen label May 2, 2022
@rjygraham
Copy link

I have encountered same fatal crash but it seems to be more general than what's mentioned above.

Steps to repro:

Repro Repo

  1. Create multi-page Android Shell Application with button to navigate from MainPage to SecondPage
  2. Start app and then exit using hardware back button (or gesture)
  3. Start app again and then attempt to navigate from MainPage to SecondPage
  4. App crashes

If debugging you will observe the stacktrace:

[me.mauishellna] Invalid ID 0x00000001.
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.companyname.mauishellnav, PID: 7648
[AndroidRuntime] java.lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment ShellItemRenderer{f54f2cc} (a7ee66a4-c80c-4f6d-8953-b98bd115c636 id=0x1)
[AndroidRuntime] 	at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:513)
[AndroidRuntime] 	at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
[AndroidRuntime] 	at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
[AndroidRuntime] 	at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1758)
[AndroidRuntime] 	at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1701)
[AndroidRuntime] 	at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:488)
[AndroidRuntime] 	at android.os.Handler.handleCallback(Handler.java:938)
[AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[AndroidRuntime] 	at android.os.Looper.loop(Looper.java:223)
[AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:7664)
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
**Java.Lang.IllegalArgumentException:** 'No view found for id 0x1 (unknown) for fragment ShellItemRenderer{f54f2cc} (a7ee66a4-c80c-4f6d-8953-b98bd115c636 id=0x1)'

Video showing crash:
https://raw.githubusercontent.com/rjygraham/MauiShellNav/main/videos/ShellItemRenderer.mp4

@VincentBu
Copy link

I can repro with rjygraham's repo on Android. vs version: 32516.383.main

@VincentBu VincentBu added the s/verified Verified / Reproducible Issue ready for Engineering Triage label May 17, 2022
@hartez hartez modified the milestones: 6.0-servicing, 6.0-sr3 Jun 27, 2022
@PureWeen PureWeen linked a pull request Jul 5, 2022 that will close this issue
@PureWeen
Copy link
Member

PureWeen commented Jul 5, 2022

@rjygraham 's issue should be fixed by this PR #8455. I'm assuming it's the same issue as the original posters as well because this is generally just a problem when the activity on android is recreated

@PureWeen PureWeen closed this as completed Jul 5, 2022
@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Jul 12, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/android 🤖 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants