Gradle找不到Android Compose编译器

Gradle找不到Android Compose编译器,android,android-gradle-plugin,android-jetpack-compose,Android,Android Gradle Plugin,Android Jetpack 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-alpha

我对这个问题很困惑。我的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
我对此感到困惑,因为编译器确实存在于谷歌的repo中:


如果需要的话,我可以发布更多的信息,但我想保持简单。即使compose的设置完全不正确,为什么它找不到POM文件?

也有同样的问题,并在将gradle版本更新为后得到解决

classpath "com.android.tools.build:gradle:4.2.0-alpha14"
而不是在composeoptions中声明编译器版本
KotlUncompileRextensionVersion
,而是标记为依赖项

implementation "androidx.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.compiler:compiler:$compose_version"

我必须升级我的Gradle版本:

buildscript {
    dependencies {
         classpath "com.android.tools.build:gradle:7.0.0-alpha02"

我遇到了一个非常类似的问题,但在IntelliJ IDEA中运行Android项目时,不是在Android Studio中

我似乎升级了
com.android.tools.build:gradle
依赖项确实解决了最初的问题(“gradle找不到android Compose编译器”),但后来我开始了,所以不得不找到另一种方法

我使用IDEA的新项目向导,然后选择Kotlin,然后选择“多平台”(在Jetpack Compose for Desktop group下)。这创建了一个包含Android模块、桌面模块和公共模块的新项目。从这个模板,我基本上复制了Android和公共模块是如何设置到我原来的Android项目中的

主要区别在于JetBrains似乎提供了一个(另一个)Gradle插件(
org.JetBrains.compose
),它为我们设置了compose(因为我想有些变化也支持桌面),有了这个插件,一切似乎都正常了,“Gradle找不到Android compose编译器”也就不见了

这是新项目模板中使用的插件:

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")
请记住,我不一定要在这里使用桌面,至少目前不需要,但这是我能够使Android应用程序与最新(2021年以上)版本的Compose with just IDEA(非Android Studio)安装一起工作的唯一方法。

3月27日/21日 Jetpack Compose是一个预览功能,对Compose的支持仅包含在Android Studio的金丝雀版本中。要在应用程序项目中使用Compose,请下载并安装最新版本的IDE


如果您使用的是Canary simpply,请使用
composeOptions

格雷德尔先生

忘了注意到我正在使用Android Studio 4.2,Canary 13您使用的是哪个版本的
com.Android.tools.build:gradle
?这也是
4.2.0-alpha13
?@ianhanniballake是的,它is@MarkHerscher有任何更新来解决这个问题吗?我也被困在这一点上:(
android {
    // ...
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion "1.0.0-beta03"
    }
}