architecture-components-samples: [NavigationBasicSample] crash

TitleScreen —> Register —> Match —> InGame —> ResultsWinner/GameOver —> Match, then click ‘Back Key’ back to Register, then click SIGN UP, crash. log: com.example.android.navigationsample E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.android.navigationsample, PID: 3184 java.lang.IllegalArgumentException: navigation destination com.example.android.navigationsample:id/action_register_to_match is unknown to this NavController at androidx.navigation.NavController.navigate(NavController.java:669) at androidx.navigation.NavController.navigate(NavController.java:628) at androidx.navigation.NavController.navigate(NavController.java:616) at com.example.android.navigationsample.Register$onCreateView$1.onClick(Register.kt:39) at android.view.View.performClick(View.java:6266) at android.view.View$PerformClick.run(View.java:24730) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:171) at android.app.ActivityThread.main(ActivityThread.java:6672) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:246) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)

就是游戏一次无论输赢,回到匹配的界面,再点击返回按钮回到登录界面,再次点登录按钮会崩溃。 原因没有找到。

英文不好,大佬看到可以帮忙翻译一下,谢谢

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (1 by maintainers)

Most upvoted comments

bug returns on 1.0.0-alpha06 ktx

java.lang.IllegalArgumentException: navigation destination com.nyx.tech.dev:id/action_home_fragment_to_calibration_fragment is unknown to this NavController
        at androidx.navigation.NavController.navigate(NavController.java:691)
        at androidx.navigation.NavController.navigate(NavController.java:648)
        at androidx.navigation.NavController.navigate(NavController.java:634)
        at androidx.navigation.NavController.navigate(NavController.java:712)
        at com.nyx.tech.fragments.home.HomeFragment.onFeatureInitiated(HomeFragment.kt:240)
        at com.nyx.tech.fragments.home.HomeFragmentPresenter$observe$1.onChanged(HomeFragmentPresenter.kt:177)
        at com.nyx.tech.fragments.home.HomeFragmentPresenter$observe$1.onChanged(HomeFragmentPresenter.kt:50)
        at android.arch.lifecycle.LiveData.considerNotify(LiveData.java:109)
        at android.arch.lifecycle.LiveData.dispatchingValue(LiveData.java:126)
        at android.arch.lifecycle.LiveData.setValue(LiveData.java:282)
        at android.arch.lifecycle.MutableLiveData.setValue(MutableLiveData.java:33)
        at android.arch.lifecycle.LiveData$1.run(LiveData.java:87)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-14 15:23:52.527 23366-23427/com.nyx.tech.dev W/NYXApplication$onCreate: com

Same happening in alpha-08 and alpha-09.

We also noticed these errors with alpha07 (Kotlin if it matters).

The root error in our case was if two navigations happened too close to one another. Say we have Fragment A, B and C. Somehow the application starts two navigations almost at the exact same time, like: A navigates to B A navigates to C

The navigation library will open fragment B, and then tries to perform the A -> C navigation, but looking at Fragment B’s actions, which leads to a crash.

Once we realised this we could easily reproduce the error.

We noticed the problem in our recycler view with different items taking the user to different fragments. One way for us to solve it was to use an Atomic boolean which is reset in OnResume and then perform a getAndSet before trying to perform the navigation.

Edit: Improved explanation

I have the same issue with alpha07