[英]Warning: NavController.setNavigatorProvider can only be called from within the same library group (groupId=androidx.navigation)
I have created a new project and met with this warning while setting up bottom-tab navigation.我创建了一个新项目,并在设置底部选项卡导航时遇到了此警告。
Gradle info Gradle 信息
My Code:我的代码:
private fun setupBottomNavigationBar() {
val navController = findNavController(R.id.nav_host_fragment)
supportFragmentManager.findFragmentById(R.id.nav_host_fragment)?.let {
val navigator = KeepStateNavigator(
this,
it.childFragmentManager,
R.id.nav_host_fragment
)
// This line gives me warning
navController.navigatorProvider += navigator
}
}
Tried solution:试过的解决方案:
// Solution 1
@SuppressLint("RestrictedApi")
private fun setupBottomNavigationBar() {
// Solution 2
// noinspection RestrictedApi
navController.navigatorProvider += navigator
Both are worked but I still don't know why I am getting this error.两者都有效,但我仍然不知道为什么会收到此错误。 Is there anything anything else that I should know that might create the problem in future?
还有什么我应该知道的可能会在将来造成问题的其他事情吗?
Any help is appreciated in advance!提前感谢任何帮助!
You might avoid warning using the below code:您可以使用以下代码避免警告:
navController.navigatorProvider.addNavigator(navigator)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.