I'm trying to create a Android plugin to create a template project. But the dependency block doesn't seem to accept aar libraries. Here is the error below:
Could not determine the dependencies of task ':prepareSandbox'.
> Could not resolve all files for configuration ':runtimeClasspath'.
> Could not resolve androidx.core:core-ktx:1.10.1.
Required by:
project :
> No matching variant of androidx.core:core-ktx:1.10.1 was found. The consumer was configured to find a library for use during runtime, compatible with Java 11, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
- Variant 'releaseVariantReleaseApiPublication' capability androidx.core:core-ktx:1.10.1 declares a library, and its dependencies declared externally:
- Incompatible because this component declares a component for use during compile-time, with the library elements 'aar' and the consumer needed a component for use during runtime, packaged as a jar
here is my build.gradle.kts which in the dependency block I've included a android dependency:
import io.gitlab.arturbosch.detekt.Detekt
import org.apache.tools.ant.taskdefs.condition.Os
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.8.0"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.13.3"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "2.0.0"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
id("io.gitlab.arturbosch.detekt") version "1.23.0-RC3"
}
val androidStudioPath: String by project
val androidStudioPathMacOS: String by project
// Import variables from gradle.properties file
val pluginGroup: String by project
// `pluginName_` variable ends with `_` because of the collision with Kotlin magic getter in the `intellij` closure.
// Read more about the issue: https://github.com/JetBrains/intellij-platform-plugin-template/issues/29
val pluginName_: String by project
val pluginVersion: String by project
val pluginSinceBuild: String by project
val platformCompilerVersion: String by project
val platformPlugins: String by project
val platformDownloadSources: String by project
group = pluginGroup
version = pluginVersion
// Configure project's dependencies
repositories {
mavenCentral()
google()
}
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1")
implementation(libs.androidxCore)
}
// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
pluginName.set(pluginName_)
localPath.set(if (Os.isFamily(Os.FAMILY_WINDOWS)) androidStudioPath else androidStudioPathMacOS)
downloadSources.set(platformDownloadSources.toBoolean())
updateSinceUntilBuild.set(true)
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(platformPlugins.split(',').map(String::trim).filter(String::isNotEmpty))
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
version.set( provider { pluginVersion } )
groups.set( provider { emptyList() } )
}
// Configure detekt plugin.
// Read more: https://detekt.github.io/detekt/kotlindsl.html
detekt {
config.setFrom("./detekt-config.yml")
autoCorrect = true
}
project.gradle.startParameter.excludedTaskNames.add("buildSearchableOptions")
tasks {
// Set the compatibility versions to 11
withType<JavaCompile> {
sourceCompatibility = "11"
targetCompatibility = "11"
}
listOf("compileKotlin", "compileTestKotlin").forEach {
getByName<KotlinCompile>(it) {
kotlinOptions.jvmTarget = "11"
}
}
patchPluginXml {
version.set(provider { pluginVersion } )
sinceBuild.set(provider { pluginSinceBuild } )
pluginDescription.set(provider {
File("./README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n")
.run { markdownToHTML(this) }
})
// Get the latest available change notes from the changelog file
changeNotes.set( provider {
changelog.render(
org.jetbrains.changelog.Changelog.OutputType.HTML)
} )
}
instrumentCode {
compilerVersion.set(provider { platformCompilerVersion })
}
publishPlugin {
dependsOn("patchChangelog")
token.set(provider { System.getenv("PUBLISH_TOKEN") })
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html#specifying-a-release-channel
channels.set(provider {
pluginVersion.split('-')
.getOrElse(1) { "default" }
.split('.')
} )
}
}
tasks.withType(Detekt::class).configureEach {
reports {
html.required.set(false)
xml.required.set(false)
txt.required.set(false)
}
}
What happened?
I'm trying to create a Android plugin to create a template project. But the dependency block doesn't seem to accept aar libraries. Here is the error below:
here is my build.gradle.kts which in the dependency block I've included a android dependency:
and here is the gradel.properties file:
the build.gradle.kts references my libs.version.toml file:
Relevant log output or stack trace
No response
Steps to reproduce
added
implementation(libs.androidxCore)
the the dependency blockGradle IntelliJ Plugin version
1.11.0
Gradle version
8.2.1
Operating System
macOS
Link to build, i.e. failing GitHub Action job
No response