Gradle 找不到 kotlin 编译器版本
2020-10-20
2028
我想配置 Jetpack Compose。我做到了,但在运行应用时每次都会出现该错误。Jetpack 在项目中,我可以使用它,但无法运行应用。
任务“:myModule:prepareDebugKotlinCompileTask”执行失败。
Could not resolve all files for configuration ':myModule:kotlin-extension'. Could not find androidx.compose:compose-compiler:1.0.0-alpha05. Searched in the following locations: - https://dl.google.com/dl/android/maven2/androidx/compose/compose-compiler/1.0.0-alpha05/compose-compiler-1.0.0-alpha05.pom
我的模块的 Gradle 文件:
plugins {
id("po-android-library")
id("kotlin-kapt")
id("de.mannodermaus.android-junit5")
}
android {
defaultConfig {
renderscriptTargetApi = AndroidSdkVersions.target
renderscriptSupportModeEnabled = true
vectorDrawables.useSupportLibrary = true
}
buildFeatures {
compose = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
composeOptions {
kotlinCompilerVersion = "1.4.0"
kotlinCompilerExtensionVersion = "1.0.0-alpha05"
}
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
testOptions.unitTests.isIncludeAndroidResources = true
sourceSets {
val sharedTestDir = "src/sharedTest/java"
getByName("test") {
java.srcDir(sharedTestDir)
}
}
packagingOptions {
pickFirst("mockito-extensions/org.mockito.plugins.MockMaker")
exclude("META-INF/rxjava.properties")
exclude("META-INF/rxkotlin.properties")
}
}
dependencies {
implementation(project(":common"))
implementation(project(":android-common"))
implementation(Deps.kotlin_stdlib)
implementation("com.android.tools.build:gradle:4.1.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10")
implementation(Deps.androidx_appcompat)
implementation(Deps.koin_android_viewmodel)
implementation(Deps.koin_androidx_ext)
implementation(Deps.koin_android)
implementation(Deps.rxkotlin)
implementation("androidx.compose.runtime:runtime:1.0.0-alpha05")
implementation("androidx.compose.ui:ui:1.0.0-alpha05")
implementation("androidx.compose.foundation:foundation-layout:1.0.0-alpha05")
implementation("androidx.compose.material:material:1.0.0-alpha05")
1个回答
从 Compose 编译器版本
1.0.0-alpha04
开始,我们应该使用
Android Studio 4.2 Canary 13
或更高版本,并且
com.android.tools.build:gradle
版本应为
4.2.0-alpha13
来自官方网站 参考
Muthukrishnan Rajendran
2020-10-20