当我尝试使用 jetpack 的 compose 库时,我被卡在了 jetpack 文档中提到的步骤(来源:https ://developer.android.com/jetpack/compose/setup#compose-compiler )。由于出现以下异常,我无法使用 kotlinPlugin。
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method kotlinPlugin() for arguments [androidx.compose:compose-compiler:0.1.0-dev02] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
此外,我无法使用darkThemeColors和lightThemeColors。以下是我添加的 Gradle 依赖项。
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
kotlinPlugin "androidx.compose:compose-compiler:0.1.0-dev02"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.ui:ui-framework:0.1.0-dev02'
implementation 'androidx.ui:ui-layout:0.1.0-dev02'
implementation 'androidx.ui:ui-material:0.1.0-dev02'
implementation 'androidx.ui:ui-tooling:0.1.0-dev02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.50'
}
我是否缺少任何依赖项?我检查了MaterialTheme和MaterialColors类,但没有找到 darkThemeColors 和 lightThemeColors。