I'm going through the official Android documentation on how to create and publish a library to my local maven repository, but when i'm following the steps I'm getting this error
Caused by: groovy.lang.MissingMethodException: No signature of method: build_ewas9zz0n0p5kxro8hw38fuu9.android() is applicable for argument types: (build_ewas9zz0n0p5kxro8hw38fuu9$_run_closure1) values: [build_ewas9zz0n0p5kxro8hw38fuu9$_run_closure1@4f16ba38]
this is build.gradle(Module level) i have come up with
apply plugin: 'com.android.library'
android {
compileSdk 32
namespace = 'com.test.lib'
publishing {
singleVariant('release') {
withSourcesJar()
}
repositories {
maven {
name = 'myrepo'
url = "${project.buildDir}/repo"
}
}
publications {
release(MavenPublication) {
groupId = 'com.test'
artifactId = 'lib'
version = '1.0'
afterEvaluate {
from components.release
}
}
}
}
defaultConfig {
minSdk 16
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
repositories {
google()
mavenCentral()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
looking up this error here , the answer suggested the gradle file is wrong, if i delete publications from by build.gradle it builds fine but does not publish to my local repository. ( running gradle publishReleaseToMyrepoRepository gives publishReleaseToMyrepoRepository Not found).
I know i have missed something or configured wrongly, but i'm not aware what is it. Any help to resolve this or to help me publish in my local repository will be grateful.
PS: I'm very new to gradle and it's configurations