With all of this, I get a crash saying it can't find the class named BottomDialog which is impossible because if I change on the mobile_navigation the tag from <dialog to <fragment it can indeed navigate but lose all the behavior that a bottom Sheet must have. I dont know if im missing something or if it's just something regarding xamarin that does not work.
Already tried to clean/rebuild, and reinstall nuggets, and still no good.
@Leon Lu (Shanghai Wicresoft Co,.Ltd.)
I thought you had a solution, from your comments above, and that was why I asking for your solution. So do you have one or not?
I'll attach my test app here, but I'm only guessing that is coded the same way as @Hugo G 's app.
I've never attempted to use a Dialog in a nav_graph in any of the NavigationGraph projects I've posted. I've explained my reasons re nav_graph limitations in the NavigationGraph.docx, but I looked up a couple of examples and as far as I can see @Hugo G was coding it as in the examples I saw, so it should have worked.
The class not found exception is common enough with a misspelled class name, but I've never seen it called from the androidx.navigation.fragment.DialogFragmentNavigator.navigate before obviously since my usual code would never be calling that code, since I don't use dialogs in nav_graphs.
https://github.com/gmck/NavigationDialogTest
the full error is the following
Process: com.companyname.navigationdialogtest, PID: 19197
androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.companyname.navigationdialogtest.dialogs.BottomDialog: make sure class name exists
at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:97)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:661)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:507)
at androidx.navigation.fragment.DialogFragmentNavigator.navigate(DialogFragmentNavigator.kt:130)
at androidx.navigation.fragment.DialogFragmentNavigator.navigate(DialogFragmentNavigator.kt:118)
at androidx.navigation.NavController.navigateInternal(NavController.kt:260)
at androidx.navigation.NavController.navigate(NavController.kt:1719)
at androidx.navigation.NavController.navigate(NavController.kt:1545)
at androidx.navigation.NavController.navigate(NavController.kt:1472)
at androidx.navigation.NavController.navigate(NavController.kt:1454)
at androidx.navigation.NavController.navigate(NavController.kt:1437)
at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:31)
at android.view.View.performClick(View.java:7506)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1219)
at android.view.View.performClickInternal(View.java:7483)
at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
at android.view.View$PerformClick.run(View.java:29341)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.ClassNotFoundException: com.companyname.navigationdialogtest.dialogs.BottomDialog
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at androidx.fragment.app.FragmentFactory.loadClass(FragmentFactory.java:53)
at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:94)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:661)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:507)
at androidx.navigation.fragment.DialogFragmentNavigator.navigate(DialogFragmentNavigator.kt:130)
at androidx.navigation.fragment.DialogFragmentNavigator.navigate(DialogFragmentNavigator.kt:118)
at androidx.navigation.NavController.navigateInternal(NavController.kt:260)
at androidx.navigation.NavController.navigate(NavController.kt:1719)
at androidx.navigation.NavController.navigate(NavController.kt:1545)
at androidx.navigation.NavController.navigate(NavController.kt:1472)
at androidx.navigation.NavController.navigate(NavController.kt:1454)
at androidx.navigation.NavController.navigate(NavController.kt:1437)
at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:31)
at android.view.View.performClick(View.java:7506)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1219)
at android.view.View.performClickInternal(View.java:7483)
at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
at android.view.View$PerformClick.run(View.java:29341)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.companyname.navigationdialogtest.dialogs.BottomDialog" on path: DexPathList[[zip file "/data/app/~~3OyG_7la9ZenUDf4EJWJOA==/com.companyname.navigationdialogtest-sVLl4WaldoDmb1hN2TvCEw==/base.apk"],nativeLibraryDirectories=[/data/app/~~3OyG_7la9ZenUDf4EJWJOA==/com.companyname.navigationdialogtest-sVLl4WaldoDmb1hN2TvCEw==/lib/arm64, /data/app/~~3OyG_7la9ZenUDf4EJWJOA==/com.companyname.navigationdialogtest-sVLl4WaldoDmb1hN2TvCEw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at androidx.fragment.app.FragmentFactory.loadClass(FragmentFactory.java:53)
at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:94)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:661)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:507)
at androidx.navigation.fragment.DialogFragmentNavigator.navigate(DialogFragmentNavigator.kt:130)
at androidx.navigation.fragment.DialogFragmentNavigator.navigate(DialogFragmentNavigator.kt:118)
at androidx.navigation.NavController.navigateInternal(NavController.kt:260)
at androidx.navigation.NavController.navigate(NavController.kt:1719)
at androidx.navigation.NavController.navigate(NavController.kt:1545)
at androidx.navigation.NavController.navigate(NavController.kt:1472)
at androidx.navigation.NavController.navigate(NavController.kt:1454)
at androidx.navigation.NavController.navigate(NavController.kt:1437)
at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:31)
at android.view.View.performClick(View.java:7506)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1219)
at android.view.View.performClickInternal(View.java:7483)
at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
at android.view.View$PerformClick.run(View.java:29341)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
yep, your app is pretty much what I got on my side.
its really weird since just a small change from <dialog to <fragment make it work(without being a bottom sheet ofc) but it does work without throwing that error hence why I think this might be something deeper I don't know..
I´ve follow docs and YouTube videos where on their side it seems to always work, but I can never make it on my side