Reputation: 114
I'm working on setting up instrumentation tests in my java library gradle project using the androidx.test library. I added the following dependency in my build.gradle file:
plugins {
id 'java-library'
}
repositories {
google()
mavenCentral()
}
dependencies {
implementation 'androidx.test:runner:1.6.2'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
However, Gradle is unable to resolve some of its transitive dependencies, resulting in build failures. I’m new to Gradle and not sure how to resolve these missing dependencies.
Here’s the error message I’m getting:
:lib:test: Could not resolve androidx.tracing:tracing:1.1.0.
Required by:
project :lib > androidx.test:runner:1.6.2
project :lib > androidx.test:runner:1.6.2 > androidx.test:monitor:1.7.2
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
What I’ve Tried:
None of these steps have resolved the issue.
Questions:
Maven repo link which I am trying to import
Output of ./gradlew :lib:dependencies
> Task :lib:dependencies
------------------------------------------------------------
Project ':lib'
------------------------------------------------------------
annotationProcessor - Annotation processors and their dependencies for source set 'main'.
No dependencies
api - API dependencies for the 'main' feature. (n)
No dependencies
apiElements - API elements for the 'main' feature. (n)
No dependencies
compileClasspath - Compile classpath for source set 'main'.
\--- androidx.test:runner:1.6.2
+--- androidx.annotation:annotation:1.7.0-beta01
| \--- androidx.annotation:annotation-jvm:1.7.0-beta01
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 -> 1.8.20
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.20
| \--- org.jetbrains:annotations:13.0
+--- androidx.test.services:storage:1.5.0
| +--- androidx.annotation:annotation:1.7.0-beta01 (*)
| \--- androidx.test:monitor:1.7.0 -> 1.7.2
| +--- androidx.annotation:annotation:1.7.0-beta01 (*)
| +--- androidx.tracing:tracing:1.1.0 FAILED
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.20 (*)
+--- androidx.test:monitor:1.7.2 (*)
+--- androidx.tracing:tracing:1.1.0 FAILED
\--- junit:junit:4.13.2
\--- org.hamcrest:hamcrest-core:1.3
compileOnly - Compile-only dependencies for the 'main' feature. (n)
No dependencies
compileOnlyApi - Compile-only API dependencies for the 'main' feature. (n)
No dependencies
default - Configuration for default artifacts. (n)
No dependencies
implementation - Implementation dependencies for the 'main' feature. (n)
\--- androidx.test:runner:1.6.2 (n)
mainSourceElements - List of source directories contained in the Main SourceSet. (n)
No dependencies
runtimeClasspath - Runtime classpath of source set 'main'.
\--- androidx.test:runner:1.6.2
+--- androidx.annotation:annotation:1.7.0-beta01
| \--- androidx.annotation:annotation-jvm:1.7.0-beta01
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 -> 1.8.20
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.20
| \--- org.jetbrains:annotations:13.0
+--- androidx.test.services:storage:1.5.0
| +--- androidx.annotation:annotation:1.7.0-beta01 (*)
| \--- androidx.test:monitor:1.7.0 -> 1.7.2
| +--- androidx.annotation:annotation:1.7.0-beta01 (*)
| +--- androidx.tracing:tracing:1.1.0 FAILED
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.20 (*)
+--- androidx.test:monitor:1.7.2 (*)
+--- androidx.tracing:tracing:1.1.0 FAILED
\--- junit:junit:4.13.2
\--- org.hamcrest:hamcrest-core:1.3
runtimeElements - Runtime elements for the 'main' feature. (n)
No dependencies
runtimeOnly - Runtime-only dependencies for the 'main' feature. (n)
No dependencies
testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
No dependencies
testCompileClasspath - Compile classpath for source set 'test'.
\--- androidx.test:runner:1.6.2
+--- androidx.annotation:annotation:1.7.0-beta01
| \--- androidx.annotation:annotation-jvm:1.7.0-beta01
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 -> 1.8.20
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.20
| \--- org.jetbrains:annotations:13.0
+--- androidx.test.services:storage:1.5.0
| +--- androidx.annotation:annotation:1.7.0-beta01 (*)
| \--- androidx.test:monitor:1.7.0 -> 1.7.2
| +--- androidx.annotation:annotation:1.7.0-beta01 (*)
| +--- androidx.tracing:tracing:1.1.0 FAILED
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.20 (*)
+--- androidx.test:monitor:1.7.2 (*)
+--- androidx.tracing:tracing:1.1.0 FAILED
\--- junit:junit:4.13.2
\--- org.hamcrest:hamcrest-core:1.3
testCompileOnly - Compile only dependencies for source set 'test'. (n)
No dependencies
testImplementation - Implementation only dependencies for source set 'test'. (n)
No dependencies
testRuntimeClasspath - Runtime classpath of source set 'test'.
\--- androidx.test:runner:1.6.2
+--- androidx.annotation:annotation:1.7.0-beta01
| \--- androidx.annotation:annotation-jvm:1.7.0-beta01
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 -> 1.8.20
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.20
| \--- org.jetbrains:annotations:13.0
+--- androidx.test.services:storage:1.5.0
| +--- androidx.annotation:annotation:1.7.0-beta01 (*)
| \--- androidx.test:monitor:1.7.0 -> 1.7.2
| +--- androidx.annotation:annotation:1.7.0-beta01 (*)
| +--- androidx.tracing:tracing:1.1.0 FAILED
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.20 (*)
+--- androidx.test:monitor:1.7.2 (*)
+--- androidx.tracing:tracing:1.1.0 FAILED
\--- junit:junit:4.13.2
\--- org.hamcrest:hamcrest-core:1.3
testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
No dependencies
(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation.
(n) - A dependency or dependency configuration that cannot be resolved.
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 666ms
1 actionable task: 1 executed
Upvotes: 1
Views: 174
Reputation: 76669
These AndroidX libraries are not really meant to be used in common Java projects,
because in general, androidx.test
merely belongs into androidTestImplementation
,
which means it ultimately depends on AGP, to create that source-set androidTest
.
It reads:
+--- androidx.tracing:tracing:1.1.0 FAILED
Try to provide a newer version, alike:
androidTestImplementation "androidx.tracing:tracing:1.2.0"
The requested version 1.1.0
would also be available on repository google()
:
https://mvnrepository.com/artifact/androidx.tracing/tracing
Declaring dependencies clearly reads androidTestImplementation
...
Upvotes: 0