我尝试运行coil import coil.compose.rememberAsyncImagePainter
,以便可以运行val painter = rememberAsyncImagePainter(model = curr.images.random()) Image(painter = painter, contentDescription = "image", modifier = Modifier.fillMaxWidth(), contentScale = ContentScale.FillWidth)
,但出现以下错误:'评估根项目' MovieApp '时出现问题。
在类型为org. gradle. api. internal. artifacts. dsl. dependencies. DefaultDependencyHandler的对象上找不到参数[io. coil-kt:coil-compose:2.2.2]的方法实现()。'
这是我的build. gradle。有人能想到我的问题出在哪里吗?
buildscript {
ext {
compose_ui_version = '1.1.1'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
dependencies {
implementation("io.coil-kt:coil-compose:2.2.2")
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.0'
implementation 'androidx.activity:activity-compose:1.6.1'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation 'androidx.compose.material:material:1.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
}
1条答案
按热度按时间vxqlmq5t1#
您正在使用顶级
build.gradle
(在根文件夹中)而不是app/module文件夹中的build.gradle
添加依赖项。