Mar*_*her 26 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-alpha04"
Run Code Online (Sandbox Code Playgroud)
但是,当我构建时,出现以下错误:
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
Run Code Online (Sandbox Code Playgroud)
我对此感到困惑,因为编译器确实存在于 Google 的 repo 中:https ://maven.google.com/web/index.html#androidx.compose.compiler:compiler
如有必要,我可以发布更多信息,但我想保持简单。即使 compose 设置完全错误,为什么也找不到 POM 文件?
Hob*_*oby 13
有同样的问题并在将 gradle 版本更新为
classpath "com.android.tools.build:gradle:4.2.0-alpha14"
Run Code Online (Sandbox Code Playgroud)
而不是kotlinCompilerExtensionVersion在 composeoptions中声明编译器版本,而是声明为依赖项
implementation "androidx.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.compiler:compiler:$compose_version"
Run Code Online (Sandbox Code Playgroud)
Arp*_*tel 13
我最近遇到了同样的问题。某些 Compose 编译器版本支持特定的 Kotlin 版本。
感谢 @Braian 的Compose 编译器
就我而言,以下版本有效。
compose_version = '1.3.0-alpha01'
和
kotlinCompilerExtensionVersion "1.2.0-beta03"
这是我的 gradle 文件供参考。
构建.gradle(:应用程序)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.hometech.composedemo"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion "1.2.0-beta03"
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.0'
implementation 'androidx.activity:activity-compose:1.5.0'
implementation 'androidx.navigation:navigation-runtime-ktx:2.5.0'
def nav_version = "2.5.0"
// Navigation Compose
implementation("androidx.navigation:navigation-compose:$nav_version")
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
//Icons
implementation "androidx.compose.material:material-icons-extended:$compose_version"
}
Run Code Online (Sandbox Code Playgroud)
build.gradle(项目级别)
buildscript {
ext {
compose_version = '1.3.0-alpha01'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
Compose 版本“1.3.0-alpha01”的最新更改
编译器版本
kotlinCompilerExtension版本 '1.3.0'
科特林版本
id 'org.jetbrains.kotlin.android' 版本 '1.7.10' 应用 false
您应该将编译器版本添加到应用程序的build.gradle:
android {
...
composeOptions {
kotlinCompilerExtensionVersion '1.3.0'
}
}
Run Code Online (Sandbox Code Playgroud)
版本应与 Kotlin 版本匹配,例如 Kotlin1.7.10应与 compose compiler 一起使用1.3.0。请参考此地图找到正确的匹配:https://developer.android.com/jetpack/androidx/releases/compose-kotlin
我不得不升级我的 Gradle 版本:
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:7.0.0-alpha02"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7625 次 |
| 最近记录: |