Gradle 5.x - Error publishing my library to Maven Local

With gradle 4.8+ you have to enclose the publishing{} block inside a project.afterEvaluate

project.afterEvaluate {
    publishing {
        publications {
            aar(MavenPublication) {
                //...
                artifact bundleReleaseAar
            }
        }
    }
}

You can find the official doc here:

Prior to Gradle 4.8, the publishing {} block was implicitly treated as if all the logic inside it was executed after the project was evaluated. This was confusing, because it was the only block that behaved that way. As part of the stabilization effort in Gradle 4.8, we are deprecating this behavior and asking all users to migrate their build.


Put this inside project.afterEvaluate:

project.afterEvaluate {
    publishing {
        publications {
            mavenDebugAAR(MavenPublication) {
                artifact bundleDebugAar
            }
        }
    }
}

you may try this.

project.afterEvaluate {
    publishing {
        publications {
            library(MavenPublication) {
            groupId = 'myGroupId'
            artifactId = 'myArtifactId'
            version = android.defaultConfig.versionName

            artifact bundleDebugAar
        }
        }
    }
}