Missing transitive dependencies for Android tests
See original GitHub issueExpected 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:
- Created a year ago
- Comments:10 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll make a PR.
Thanks for the investigation @SimonMarquis!
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
andio.mockk:mock-android
, I think?) would help, and hopefully be clearer that they’re the projects that are specifically for public consumption?