我有一个项目和一个 lib 模块(该项目基本上是 lib 模块的包装器,用于创建 .aar)。预计它会像这样工作:在构建项目之后,应该构建 lib 模块,并.aar
在文件夹中生成build-> output
,该文件夹已经可以在需要时使用。但问题是它没有被创建。
必须说的是,项目中有2个lib模块,每次都成功生成第二个lib-module.aar文件,也就是说,很明显第一个lib模块没有创建的地方有问题.aar
。
我尝试过清理、重建、无效和所有这些事情,但它不起作用。
猜猜可能是什么问题?
是否可以(也许通过日志)检查工作室试图在哪里创建.aar
?或者如何更改文件的保存位置?或者只是看一些关于它的创作的信息?
UPD
未生成该模块的gradle文件
import org.jetbrains.kotlin.gradle.plugin.myproject.KotlinNativeTarget
plugins {
kotlin("multiplatform")
id("com.android.library")
id("maven-publish")
id("kotlin-android-extensions")
}
var frameworkName = "myframeworkname"
group = "here.my.library"
version = "0.0.2"
kotlin {
android()
ios {
compilations.forEach {
it.kotlinOptions.freeCompilerArgs += arrayOf("-linker-options", "-application_extension")
}
binaries {
framework {
baseName = "mybasename"
embedBitcode("disable")
}
}
}
tvos {
compilations.forEach {
it.kotlinOptions.freeCompilerArgs += arrayOf("-linker-options", "-application_extension")
}
binaries {
framework {
baseName = "mybasename"
embedBitcode("bitcode")
}
}
}
sourceSets {
val commonMain by getting
val androidMain by getting {
dependencies {
implementation("com.google.android.material:material:1.2.1")
}
}
val iosMain by getting
val tvosMain by getting {
dependsOn(iosMain)
}
val iosTest by getting
val tvosTest by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
}
android {
publishLibraryVariants("release", "debug")
}
configure(listOf(targets["metadata"], android())) {
mavenPublication {
val targetPublication = this@mavenPublication
tasks.withType<AbstractPublishToMaven>()
.matching { it.publication == targetPublication }
}
}
}
android {
compileSdk = 30
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 24
targetSdk = 30
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
}
publishing {
println("Project dir : ${projectDir.name}")
publications {
create<MavenPublication>("lib") {
groupId = "entpay.shared.library"
artifactId = project.name
version = project.version as String?
artifact("$buildDir/outputs/aar/${projectDir.name}-release.aar")
}
}
repositories {
mavenLocal()
}
}
val packForXcode by tasks.creating(Sync::class) {
val xcodeMode = if (System.getenv("CONFIGURATION").equals("release", true)) "RELEASE" else "DEBUG"
val frameworksDirectory = File(buildDir, "xcode-frameworks")
val target = System.getProperty("TARGET_PLATFORM") ?: "iosX64"
println("target = ${target}")
println("configuration = ${xcodeMode}")
group = "build"
inputs.property("mode", xcodeMode)
val framework = kotlin.targets.getByName<KotlinNativeTarget>(target).binaries.getFramework(xcodeMode)
dependsOn(framework.linkTask)
from({ framework.outputDirectory })
val path = File(frameworksDirectory,target)
into(path)
}
tasks.getByName("build").dependsOn(packForXcode)
最后这个答案帮助了我 - https://stackoverflow.com/a/20927125/5709159,即通过终端的命令 -
/gradlew assembleRelease
(或/gradlew assembleDebug
)