Why does android.arch.navigation cause Program type already present: android.support.v4.os.ResultReceiver$1?

↘锁芯ラ 提交于 2019-12-01 05:43:22

I've been looking at this issue and I have sorted the main issue here by excluding the support package when adding the dependency to the library, doing this:

implementation("android.arch.navigation:navigation-fragment:$nav_version") {
  exclude group: 'com.android.support'
}

That would allow you to run the application. However, this artifact is using the support artifacts rather than the androidx artifacts. Looking at the documentation, we can see that NavHostFragment is extending support.v4.Fragment https://developer.android.com/reference/androidx/navigation/fragment/NavHostFragment

So, in short, you are presented with three options, as far as I can see. The first one is to drop the androidx artifacts and use the support ones which eventually depends on how big your app is.

The second option is to drop the navigation library and go back to the classic way of dealing with navigation which, I guess, is probably undesirable for you.

The third option is to implement a navigation host of your own which I don't know how much work it would be.

This response will remain accurate until Google releases the androidx version of the library which I am surprised they haven't already.

Hope that was helpful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!