最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - Multi module project - Multiple Library Versions - Stack Overflow

programmeradmin3浏览0评论

I am working on a multi Module Android project and I want to use the latest navigation library so I can take advantage of the Type Safe Navigation.

Just usual I added the library reference into the libs file and included that into the main module library

navigationVersion = "2.8.9"
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationVersion" }


dependencies {
    implementation(libs.jakewharton.timber)
    implementation(libs.androidx.security.cryto.ktx)
    implementation(libs.bundlespose)
    implementation(libs.androidx.activity.kotlin)
    implementation(libs.androidx.core.splashscreen)
    implementation(libs.androidx.core.ktx)
    implementation(libs.jetbrains.kotlinx.collections.immutable)
    implementation(libs.google.android.gms.maps)
    implementation(libs.androidx.navigationpose) - HERE IS THE LIBRARY
....

and I am trying to use the typesafe navigation method but it keeps throwing me the issue it does not exist

    @Serializable
    data object Name

navHostController.navigate(Name)

Error code:

None of the following functions can be called with the arguments supplied.
navigate(Uri) defined in androidx. navigation. NavHostController
navigate(NavDeepLinkRequest) defined in androidx. navigation. NavHostController
navigate(NavDirections) defined in androidx. navigation. NavHostController
navigate(Int) defined in androidx. navigation. NavHostController
navigate(String, NavOptions? = ..., Navigator. Extras? = ...) defined in androidx. navigation. NavHostControlle

Then I noticed for some reason a 2.5.1 version is also presented in the project somehow besides the 2.8.9 version - but when I try to include the NavHostController it uses it from the 2.5.1 version

There is no 2.5.1 version somehwere for this library reference on the libs.toml so I have zero clue where they come from.

And while I was checking this I also realized there are a lot of libraries with multiple different versions.

Why so? How could I detect or remove where or how the older versions are included?

I am working on a multi Module Android project and I want to use the latest navigation library so I can take advantage of the Type Safe Navigation.

Just usual I added the library reference into the libs file and included that into the main module library

navigationVersion = "2.8.9"
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationVersion" }


dependencies {
    implementation(libs.jakewharton.timber)
    implementation(libs.androidx.security.cryto.ktx)
    implementation(libs.bundlespose)
    implementation(libs.androidx.activity.kotlin)
    implementation(libs.androidx.core.splashscreen)
    implementation(libs.androidx.core.ktx)
    implementation(libs..jetbrains.kotlinx.collections.immutable)
    implementation(libs.google.android.gms.maps)
    implementation(libs.androidx.navigationpose) - HERE IS THE LIBRARY
....

and I am trying to use the typesafe navigation method but it keeps throwing me the issue it does not exist

    @Serializable
    data object Name

navHostController.navigate(Name)

Error code:

None of the following functions can be called with the arguments supplied.
navigate(Uri) defined in androidx. navigation. NavHostController
navigate(NavDeepLinkRequest) defined in androidx. navigation. NavHostController
navigate(NavDirections) defined in androidx. navigation. NavHostController
navigate(Int) defined in androidx. navigation. NavHostController
navigate(String, NavOptions? = ..., Navigator. Extras? = ...) defined in androidx. navigation. NavHostControlle

Then I noticed for some reason a 2.5.1 version is also presented in the project somehow besides the 2.8.9 version - but when I try to include the NavHostController it uses it from the 2.5.1 version

There is no 2.5.1 version somehwere for this library reference on the libs.toml so I have zero clue where they come from.

And while I was checking this I also realized there are a lot of libraries with multiple different versions.

Why so? How could I detect or remove where or how the older versions are included?

Share Improve this question asked Mar 15 at 21:32 No_NameNo_Name 3033 silver badges11 bronze badges 1
  • Any chance you have other dependencies that are brining those in? – tomerpacific Commented Mar 16 at 5:32
Add a comment  | 

1 Answer 1

Reset to default 1

It looks like another library has a dependency on a lower version of the navigation. You can identify the problem by running and analyzing the file:

./gradlew :app:dependencies > dependencies.txt

But if you want to have only one version in the project, you can do so by using resolutionStrategy:

configurations.all {
  resolutionStrategy {
    force 'androidx.navigation:navigation-compose:2.8.9'
  }
}

More information about the ResolutionStrategy: https://docs.gradle./current/dsl/.gradle.api.artifacts.ResolutionStrategy.html

发布评论

评论列表(0)

  1. 暂无评论