最近我开始在一个Kotlin多平台项目上工作,我开始的时候没有任何经验,我得到了一个已经创建了基础的项目。创建该项目的开发人员有想法在Android开发部分使用组合库。后来他辞职了,我就开始干了。但是我选择不使用compose,因为交付应用程序的速度太快了。
因此,项目gradle版本目前在6.8
上,android插件在7.0.0-alpha05
上,但我想降级以停止在金丝雀版本上使用Android Studio,并在稳定版本上使用。但是当我降级gradle时,我得到了这个错误:
A problem occurred configuring project ':shared'.
> Failed to notify project evaluation listener.
> /Users/jhonata/Documents/Projetos/Aurea/quicktendr-mgmt/shared/src/main/AndroidManifest.xml (No such file or directory)
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':shared'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:68)
at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:51)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:191)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at ...
gradle属性:
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
共享gradle:
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
id("com.android.library")
id("kotlin-parcelize")
id("dev.icerock.mobile.multiplatform-resources")
kotlin("plugin.serialization")
}
android {
configurations {
create("androidTestApi")
create("androidTestDebugApi")
create("androidTestReleaseApi")
create("testApi")
create("testDebugApi")
create("testReleaseApi")
}
}
kotlin {
// jvm()
android()
ios {
binaries {
framework {
baseName = "shared"
when (val target = this.compilation.target.name) {
"iosX64" -> {
export(Deps.Decompose.iosX64)
}
"iosArm64" -> {
export(Deps.Decompose.iosArm64)
}
else -> error("Unsupported target: $target")
}
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
api(Deps.Decompose.decompose)
api(Deps.coroutines)
implementation(Deps.ktxSerializationJson)
implementation(Deps.ktorCore)
implementation(Deps.ktorSerialization)
implementation(Deps.kissMeCommon)
implementation("ch.qos.logback:logback-classic:1.2.3")
implementation("dev.icerock.moko:mvvm-core:0.10.1")
implementation("dev.icerock.moko:mvvm-livedata:0.10.1")
api("dev.icerock.moko:resources:0.15.1")
api("dev.icerock.moko:mvvm:0.9.1")
implementation("io.ktor:ktor-client-logging:1.4.2")
implementation("io.ktor:ktor-client-auth:1.4.2")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
// val mobileMain by creating {
// dependsOn(commonMain)
// dependencies {
//
// }
// }
val androidMain by getting {
dependencies {
implementation(Deps.ktorAndroid)
implementation(Deps.kissMeAndroid)
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13")
}
}
val iosMain by getting {
dependencies {
implementation(Deps.ktorIOS)
implementation(Deps.kissMeIOS)
}
}
val iosTest by getting
// val jvmMain by getting {
// dependencies {
// implementation("io.ktor:ktor-client-okhttp:1.4.2")
// }
// }
named("iosX64Main") {
dependencies {
api(Deps.Decompose.iosX64)
}
}
named("iosArm64Main") {
dependencies {
api(Deps.Decompose.iosArm64)
}
}
}
}
multiplatformResources {
multiplatformResourcesPackage = "com.quicktendr.mgmt" // required
iosBaseLocalizationRegion = "es" // optional, default "en"
}
android {
compileSdkVersion(29)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(24)
targetSdkVersion(29)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
val framework =
kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)
Gradle:
buildscript {
repositories {
gradlePluginPortal()
jcenter()
google()
mavenCentral()
maven("https://kotlin.bintray.com/kotlinx")
maven("https://dl.bintray.com/jetbrains/kotlin-native-dependencies")
maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://dl.bintray.com/icerockdev/plugins")
}
dependencies {
val kotlinVersion = "1.4.31"
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
classpath("com.android.tools.build:gradle:4.2.1")
classpath("com.github.jengelman.gradle.plugins:shadow:5.2.0")
classpath("dev.icerock.moko:resources-generator:0.15.1")
classpath("com.google.gms:google-services:4.3.5")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.5.2")
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven("https://dl.bintray.com/arkivanov/maven")
maven("https://dl.bintray.com/icerockdev/moko")
maven("https://dl.bintray.com/netguru/maven/")
maven("https://repo.repsy.io/mvn/chrynan/public")
maven("https://jitpack.io")
}
}
2条答案
按热度按时间jgwigjjp1#
如果你只是想降级gradle,你可以在你发布的gradle属性文件中降级gradle。
您需要将其设置为Android Studio 4.2.1支持的最新版本。此外,还需要考虑与Android gradle插件的兼容性。你可以在这里看到一个兼容性矩阵:
https://developer.android.com/studio/releases/gradle-plugin#4-2-0
请注意,如果您的项目使用的是依赖于特定版本的AGP/Gradle的组合,您可能需要重写这些部分。使用android studio的金丝雀版本或intellij的最新版本是可以的-除非你遇到了一些问题。您可以使用
AndroidView
一起使用compose和旧视图类https://developer.android.com/jetpack/compose/interop/interop-apis#views-in-compose
cyvaqqii2#
要降级Gradle,您需要在项目的build.gradle文件中设置所需的版本:
然后,您还需要通过在www.example.com文件中设置版本来降级Gradle Package 器gradle.wrapper.properties:
请注意,Gradle版本和Gradle Package 器版本通常不匹配。只需将Gradle Package 器设置为与Gradle相同的版本,然后Android Studio就会将其更正为正确的版本。