Код: Выделить всё
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'
android {
namespace "com.example.preferences"
compileSdk Integer.parseInt(ANDROID_BUILD_SDK_VERSION)
defaultConfig {
minSdkVersion 26
targetSdkVersion 36
versionName 0.0.1
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
publishing {
singleVariant("release") {
withJavadocJar()
}
singleVariant("debug") {
withJavadocJar()
withSourcesJar()
}
}
}
publishing {
singleVariant("debug") {
withSourcesJar()
}
singleVariant("release") {
withSourcesJar()
}
publications {
release(MavenPublication) {
artifactId = 'preferences'
afterEvaluate {
from components.release
}
}
debug(MavenPublication) {
artifactId = 'preferences-debug'
afterEvaluate {
from components.debug
}
}
withType(MavenPublication).configureEach {
pom {
name = 'Preferences library'
description = 'A library for managing application preferences in Android.'
url = 'https://github.com/example/libraries'
}
}
}
repositories {
maven {
name = 'GitHubPackages'
url = uri('https://maven.pkg.github.com/example/libraries')
credentials {
username = (project.findProperty('gpr.user') ?: System.getenv('GITHUB_ACTOR'))
password = (project.findProperty('gpr.key') ?: System.getenv('GITHUB_TOKEN'))
}
}
}
}
, которая создает ошибку:
Код: Выделить всё
Publishing is not able to resolve a dependency on a project with multiple publications that have different coordinates.
Found the following publications in project ':preferences':
- Maven publication 'release' with coordinates com.example:preferences:7.0.0
- Maven publication 'debug' with coordinates com.example:preferences-debug:7.0.0
< /code>
Я попробовал, из этого примера: https://android.googlesource.com/platform/tools/base/+/2e1ff8e3b05a4fcaad12066c6f38633b6875a2 AE/BUILD-SYSTEM/GRADLE-API/SRC/MAIN/JAVA/COM/ANDROID/BUILD/API/DSL/LibraryPublishing.kt
multipleVariants("allTypes") {
includeBuildTypeValues("debug", "release")
withJavadocJar()
withSourcesJar()
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... t-work-out
Мобильная версия