我对这个问题感到非常困惑。我的gradle文件中有以下几行:
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"但是,当我构建时,我得到以下错误:
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的repo中:
https://maven.google.com/web/index.html#androidx.compose.compiler:compiler
如果需要,我可以发布更多信息,但我想保持简单。即使compose的设置完全错误,为什么它找不到POM文件?
发布于 2020-10-22 23:48:58
有相同的问题,并在将gradle版本更新为后得到解决
classpath "com.android.tools.build:gradle:4.2.0-alpha14"而不是声明编译器版本
在composeoptions中,将其取消为依赖项
implementation "androidx.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.compiler:compiler:$compose_version"发布于 2020-12-14 04:33:42
我不得不升级我的Gradle版本:
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:7.0.0-alpha02"发布于 2021-03-01 16:40:50
我遇到了一个非常类似的问题,但是当我在IntelliJ IDEA中运行一个安卓项目时,而不是在安卓Studio中。
我认为升级
依赖确实修复了最初的问题("Gradle找不到Android Compose Compiler"),但后来我开始
其他问题
,所以必须找到另一种方法。
我使用了IDEA的新项目向导,然后选择Kotlin,然后选择“多平台”(在Jetpack Compose for Desktop组下)。这将创建一个包含Android模块、Desktop模块和Common模块的新项目。从这个模板中,我基本上复制了Android和Common模块是如何设置到我的原始Android项目中的。
主要区别在于JetBrains似乎提供了一个(又一个) Gradle插件(
)为我们设置了Compose (我猜是因为一些改变也支持桌面),有了这个插件,一切似乎都正常了,"Gradle找不到Android Compose Compiler“也消失了。
这是新项目模板中使用的插件:
id("org.jetbrains.compose") version "0.3.0"下面是如何添加组合依赖项的:
api("androidx.core:core-ktx:1.3.2")
api(compose.runtime)
api(compose.foundation)
api(compose.material)
api(compose.ui)
implementation("androidx.activity:activity-compose:1.3.0-alpha03")请记住,我在这里并不一定要使用桌面,至少现在不是,但这是我让安卓应用程序与最新(2021+)版本的Compose一起工作的唯一方法,只需安装IDEA (而不是Android Studio)即可。
https://stackoverflow.com/questions/64377577
复制相似问题