I'm trying to integrate KMM library I made with my Android project. Till now I've successfully published the KMM library locally by following the steps here
But unfortunately when trying to add it as a dependency in my Android project the project doesn't build:
Execution failed for task ':app:mergeDebugNativeLibs'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.example.kmm:core-android:1.0.0-snapshot.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/example/kmm/core-android/1.0.0-snapshot.1/core-android-1.0.0-snapshot.1.pom
- https://repo.maven.apache.org/maven2/com/example/kmm/core-android/1.0.0-snapshot.1/core-android-1.0.0-snapshot.1.pom
Required by:
project :app
I've already added mavenLocal()
to my repositories
repositories {
google()
mavenCentral()
mavenLocal()
}
But still getting nothing, any help ?
Note: when trying to consume the library in another KMM project or Module it successfully builds.
CodePudding user response:
By default, no artifacts of an Android library are published. To publish artifacts, you need to add below config in your gradle file.
kotlin {
android {
publishLibraryVariants("release", "debug")
}
}
Please check here for the details: https://kotlinlang.org/docs/mpp-publish-lib.html#publish-an-android-library
CodePudding user response:
Seems like a trivial mistake
I was trying to add mavenLocal()
repository to the project build.gradle
file when I was supposed to add it to the settings.gradle
file which obviously overrides the repositories declared in the build.gradle