android - Gradle 找不到 Android Compose 编译器
问题描述
我对这个问题感到非常困惑。我的 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 的仓库中:https ://maven.google.com/web/index.html#androidx.compose.compiler:compiler
如有必要,我可以发布更多信息,但我想保持简单。即使compose设置完全错误,为什么它找不到POM文件?
解决方案
更新 gradle 版本后遇到同样的问题并解决
classpath "com.android.tools.build:gradle:4.2.0-alpha14"
而不是kotlinCompilerExtensionVersion
在 composeoptions 中声明编译器版本,而是作为依赖项
implementation "androidx.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.compiler:compiler:$compose_version"
推荐阅读
- go - 以字符串形式返回的步骤实现河内塔的有效方法
- android - 广播接收器不工作 - 为什么会这样?
- php - 当我将 PHP 与 Mysql 一起使用时,来自数据库的 URL 不正确
- git - 如何将“Origin/master”分支转移到本地分支?
- webpack - 在ckeditor5中集成自定义下拉列表不起作用
- python - 如何对包含单词列表的 DataFrame 行进行聚类?
- java - 在添加值的循环外部访问时,ArrayList 值更改为最后一个元素
- javascript - JSON解析以获取父名称
- git - 是否有任何可用的 CodeLens 附加组件显示给定方法的 git 历史记录?
- sql-server - 使用“0”参数调用“ExecuteNonQuery”的异常