Skip to content

The aar output file is renamed to something different #95

@StefMa

Description

@StefMa

Thanks to @lukaszkalnik we found out that the aar output file is renamed in a specific combination of the AGP and Gradle version.
They renamed the file from XY-buildType to XY-version.
I found out this happend with the AGP 3.3.1 and Gradle 5.1+.
Therefore this is not guaranteed anymore and break the build.

Anyway. Depending on a hardcoded output path is not recommended by Gradle anyway.
This code

artifact("${project.buildDir}/outputs/aar/${variantName.aarFileName(project.name)}") {
will break.
Because the output is not named xy-release.aar anymore but xy-1.0.0.aar.
But I found out that the bundleReleaseAar has declared the output path:

afterEvaluate {
  println(tasks.getByName("bundleReleaseAar").outputs.hasOutput)
  tasks.getByName("bundleReleaseAar").outputs.files.forEach {
    println(it)
  }
}

true
/private/tmp/[aproject]/[aproject]/build/outputs/aar/blewifiprov-0.1.0.aar

That means we could add the artifact from this output instead of adding a hardcoded string...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions