由于撰写编译器错误,项目无法构建。添加“androidx.compose.compiler:compiler”依赖项不会修复错误。
App build.gradle.kts 文件:
val compose_version = "1.0.0-beta09"
dependencies {
implementation(project(":mpp-library"))
implementation("androidx.activity:activity-compose:1.3.0-beta02")
implementation("androidx.compose.ui:ui:${compose_version}")
implementation("androidx.compose.foundation:foundation:1.0.0-beta09")
implementation("androidx.compose.material:material:1.0.0-beta09")
implementation("androidx.compose.material:material-icons-core:1.0.0-beta09")
implementation("androidx.compose.material:material-icons-extended:${compose_version}")
implementation("androidx.compose.ui:ui-tooling:$compose_version")
implementation("androidx.compose.compiler:compiler:1.0.0-beta09")
}
multiplatformUnits {
classesPackage = "com.test.app"
dataBindingPackage = "com.test.app"
layoutsSourceSet = "main"
}
android {
compileSdkVersion(30)
defaultConfig {
applicationId = "com.test.app"
minSdkVersion(21)
targetSdkVersion(30)
versionCode = 1
versionName = "1.0"
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
buildFeatures {
compose = true
viewBinding = true
}
packagingOptions {
exclude("META-INF/*.kotlin_module")
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
composeOptions {
kotlinCompilerExtensionVersion = compose_version
}
}
由于错误甚至添加了编译器依赖项,代码无法编译:
任务“:android-app:prepareDebugKotlinCompileTask”执行失败。 > 无法解析配置 ':android-app:kotlin-extension' 的所有文件。 > 找不到 androidx.compose:compose-compiler:1.0.0-beta09。
在以下位置搜索:
- https://repo.maven.apache.org/maven2/androidx/compose/compose-compiler/1.0.0-beta09/compose-compiler-1.0.0-beta09.pom
- https://dl.google.com/dl/android/maven2/androidx/compose/compose-compiler/1.0.0-beta09/compose-compiler-1.0.0-beta09.pom
- https://jcenter.bintray.com/androidx/compose/compose-compiler/1.0.0-beta09/compose-compiler-1.0.0-beta09.pom
Required by:
project :android-app
如何修复这个错误?
答案 0 :(得分:0)
无法解析所有配置文件 ':android-app:kotlin-extension'。找不到 androidx.compose:compose-compiler:1.0.0-beta09.
不要androidx.compose:compose-compiler
做androidx.compose.compiler:compiler
你应该使用
implementation("androidx.compose.compiler:compiler:1.0.0-beta09")