Gradle 找不到 Android Compose 编译器 [英] Gradle cannot find Android Compose Compiler
问题描述
我对这个问题感到非常困惑.我的 gradle 文件中有以下几行:
I am very perplexed by this issue. I have the following lines in my gradle file:
implementation "androidx.compose.runtime:runtime:1.0.0-alpha04"
implementation "androidx.compose.compiler:compiler:1.0.0-alpha04"
implementation "androidx.compose.runtime:runtime-rxjava2:1.0.0-alpha04"
但是,当我构建时,出现以下错误:
However, when I build, I get the following error:
Could not determine the dependencies of task ':app-name-omitted:prepareDebugKotlinCompileTask'.
> Could not resolve all task dependencies for configuration ':app-name-omitted:kotlin-extension'.
> Could not find androidx.compose:compose-compiler:1.0.0-alpha04.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/androidx/compose/compose-compiler/1.0.0-alpha04/compose-compiler-1.0.0-alpha04.pom
- https://repo.maven.apache.org/maven2/androidx/compose/compose-compiler/1.0.0-alpha04/compose-compiler-1.0.0-alpha04.pom
- https://jcenter.bintray.com/androidx/compose/compose-compiler/1.0.0-alpha04/compose-compiler-1.0.0-alpha04.pom
Required by:
project :app-name-omitted
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
我对此感到困惑,因为编译器确实存在于 Google 的存储库中:https://maven.google.com/web/index.html#androidx.compose.compiler:compiler
I am confused by this, because the compiler DOES exist in Google's repo: https://maven.google.com/web/index.html#androidx.compose.compiler:compiler
如有必要,我可以发布更多信息,但我想保持简单.即使compose设置完全错误,为什么也找不到POM文件?
I can post more information if necessary, but I wanted to keep it simple. Even if compose is set up completely incorrectly, why would it not find the POM file?
推荐答案
有同样的问题并在更新 gradle 版本后解决
Had the same issue and resolved after updating the gradle version to
classpath "com.android.tools.build:gradle:4.2.0-alpha14"
并且不是在 composeoptions 中声明编译器版本 kotlinCompilerExtensionVersion
,而是声明为依赖项
and instead of declaring compiler version kotlinCompilerExtensionVersion
in the composeoptions, decalred as a dependency
implementation "androidx.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.compiler:compiler:$compose_version"
这篇关于Gradle 找不到 Android Compose 编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!