question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing transitive dependencies for Android tests

See original GitHub issue

Expected Behavior

Compilation should just work with the default gradle/maven setup:

androidTestImplementation "io.mockk:mockk-android:1.12.7"
androidTestImplementation "io.mockk:mockk-agent-jvm:1.12.7"

Source: https://mockk.io/#gradlemaven-dependency

Current Behavior

The public mockk dsl is not available for the androidTest configuration: io.mockk.mockk, io.mockk.verify

Though it is available for the regular test configuration when adding dependencies with testImplementation.


Here are the resolved dependencies: (I removed all non-mockk dependencies for clarity)

  • gradlew dependencies --configuration debugAndroidTestCompileClasspath

    debugAndroidTestCompileClasspath - Compile classpath for compilation 'debugAndroidTest' (target  (androidJvm)).
    +--- io.mockk:mockk-android:1.12.7
    +--- io.mockk:mockk-agent-jvm:1.12.7
    |    +--- io.mockk:mockk-agent-api:1.12.7
    |         \--- io.mockk:mockk-agent-api-jvm:1.12.7
    +--- io.mockk:mockk-android:{strictly 1.12.7} -> 1.12.7 (c)
    +--- io.mockk:mockk-agent-jvm:{strictly 1.12.7} -> 1.12.7 (c)
    +--- io.mockk:mockk-agent-api:{strictly 1.12.7} -> 1.12.7 (c)
    \--- io.mockk:mockk-agent-api-jvm:{strictly 1.12.7} -> 1.12.7 (c)
    
  • gradlew dependencies --configuration debugAndroidTestRuntimeClasspath

    debugAndroidTestRuntimeClasspath - Runtime classpath of compilation 'debugAndroidTest' (target  (androidJvm)).
    +--- io.mockk:mockk-android:1.12.7
    |    +--- io.mockk:mockk:1.12.7
    |    |    \--- io.mockk:mockk-jvm:1.12.7
    |    |         +--- io.mockk:mockk-dsl:1.12.7
    |    |         |    \--- io.mockk:mockk-dsl-jvm:1.12.7
    |    |         +--- io.mockk:mockk-agent:1.12.7
    |    |         |    \--- io.mockk:mockk-agent-jvm:1.12.7
    |    |         |         +--- io.mockk:mockk-agent-api:1.12.7
    |    |         |              \--- io.mockk:mockk-agent-api-jvm:1.12.7
    |    |         \--- io.mockk:mockk-agent-api:1.12.7 (*)
    |    +--- io.mockk:mockk-agent-api:1.12.7 (*)
    |    +--- io.mockk:mockk-agent-android:1.12.7
    |         +--- io.mockk:mockk-agent-api:1.12.7 (*)
    |         \--- io.mockk:mockk-agent:1.12.7 (*)
    \--- io.mockk:mockk-agent-jvm:1.12.7 (*)
    

It seems that the io.mockk:mockk artifact is not part of the compilation classpath, but only a runtime dependency.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
aSemycommented, Aug 25, 2022

I’ll make a PR.

Thanks for the investigation @SimonMarquis!

1reaction
aSemycommented, Aug 25, 2022

This makes sense! I think the api(...) definitions got lost during the Kotlin Multiplatform update.

https://github.com/mockk/mockk/blob/7dc1169c6d59973fa2175bee561a35599e914af3/mockk/android/build.gradle.kts#L53-L55

It can be confusing having too many api defs, so only setting them in ‘public’ projects (io.mockk:mockk and io.mockk:mock-android, I think?) would help, and hopefully be clearer that they’re the projects that are specifically for public consumption?

Read more comments on GitHub >

github_iconTop Results From Across the Web

gradle 7 missing transitive dependencies
I just upgraded my projects to gradle 7 and am running into missing transitive dependencies. I tried switching my build.gradle file to use ......
Read more >
Android Gradle and the curious case of invisible dependency
This is called Transitive dependency and Gradle needs to include all the direct/indirect dependencies in the app. What's happening is that Android Studio ......
Read more >
Add build dependencies
The dependencies can be located on your machine or in a remote repository, and any transitive dependencies they declare are automatically included as...
Read more >
Downgrading versions and excluding dependencies
Overriding transitive dependency versions. Gradle resolves any dependency version conflicts by selecting the latest version found in the dependency graph. Some ...
Read more >
Android 101: Gradle dependencies
Dependency tree can be displayed via ./gradlew dependencies task. This will display all direct and transitive dependencies.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found