【发布时间】:2021-08-14 13:20:57
【问题描述】:
您能否告知代码有什么问题:我在构建时遇到 JVM 错误:
Kotlin 版本 = 1.5.21
撰写版本 = 1.0.1
原因:org.jetbrains.kotlin.codegen.CompilationException:后端(JVM)内部错误:无法将内联方法调用“记住”到 @androidx.compose.runtime.Composable public fun TelephoneEditText(
$composer: androidx.compose.runtime.Composer?,$changed: kotlin.Int): com.example.scrapper.ui 中定义的kotlin.Unit 原因:未生成 文件未知 引发 java.lang.IllegalStateException 的根本原因是:org.jetbrains.kotlin.codegen.inline.InlineCodegen$Companion.getCompiledMethodNodeInner(InlineCodegen.kt:578) 在 org.jetbrains.kotlin.codegen.inline.InlineCodegen.throwCompilationException(InlineCodegen.kt:101) 在 org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:141)
@Preview
@Composable
fun TextEditOnScreen() {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
TelephoneEditText()
}
}
@Composable
fun TelephoneEditText() {
val textValue = remember {
mutableStateOf("")
}
val primaryColor = colorResource(id = R.color.design_default_color_primary)
OutlinedTextField(
label = { Text(text = stringResource(id =
R.string.phoneNumber)) },
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = primaryColor,
focusedLabelColor = primaryColor,
cursorColor = primaryColor
),
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
value = textValue.value,
onValueChange = {textValue.value = it},
)
}
已解决
替换:
implementation 'androidx.ui:ui-foundation:0.1.0-dev14'
与
implementation "androidx.compose.foundation:foundation:$compose_version"
【问题讨论】:
标签: android kotlin android-jetpack-compose