gpt4 book ai didi

android - 找不到 'kotlinPlugin' 和 'darkThemeColors'

转载 作者:行者123 更新时间:2023-11-29 16:28:31 27 4
gpt4 key购买 nike

当我尝试使用 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.

此外,我无法使用darkThemeColorslightThemeColors。以下是我添加的 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'
}

我是否缺少任何依赖项?我检查了 MaterialThemeMaterialColors 类,但没有找到 darkThemeColors 和 lightThemeColors。

最佳答案

jetpackCompose示例应用程序 jetnews darkThemeColorslightThemeColorsThemes.kt 中定义下面的文件示例,因此您需要定义颜色。

val lightThemeColors = MaterialColors(
primary = Color(0xFFDD0D3C),
primaryVariant = Color(0xFFC20029),
onPrimary = Color.White,
secondary = Color.White,
onSecondary = Color.Black,
background = Color.White,
onBackground = Color.Black,
surface = Color.White,
onSurface = Color.Black,
error = Color(0xFFD00036),
onError = Color.White
)

/**
* Note: Dark Theme support is not yet available, it will come in 2020. This is just an example of
* using dark colors.
*/
val darkThemeColors = MaterialColors(
primary = Color(0xFFEA6D7E),
primaryVariant = Color(0xFFDD0D3E),
onPrimary = Color.Black,
secondary = Color(0xFF121212),
onSecondary = Color.White,
surface = Color(0xFF121212),
background = Color(0xFF121212),
onBackground = Color.White,
onSurface = Color.White
)

在下面的 jetnews 截图中项目 enter image description here对于 jetnews样本检查此链接 https://developer.android.com/jetpack/compose/setup#sample

关于android - 找不到 'kotlinPlugin' 和 'darkThemeColors',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58551926/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com