java.lang.IllegalStateException: 函数 = <anonymous>, 计数 = 4, 索引 = 4
java.lang.IllegalStateException: function = <anonymous>, count = 4, index = 4
我在构建项目时遇到此错误
java.lang.IllegalStateException: function = <anonymous>, count = 4, index = 4
at androidx.compose.compiler.plugins.kotlin.lower.ComposerLambdaMemoization.wrapFunctionExpression(ComposerLambdaMemoization.kt:697)
at androidx.compose.compiler.plugins.kotlin.lower.ComposerLambdaMemoization.visitComposableFunctionExpression(ComposerLambdaMemoization.kt:544)
at androidx.compose.compiler.plugins.kotlin.lower.ComposerLambdaMemoization.visitFunctionExpression(ComposerLambdaMemoization.kt:608)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFunctionExpression(IrElementTransformerVoid.kt:235)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFunctionExpression(IrElementTransformerVoid.kt:24)
at org.jetbrains.kotlin.ir.expressions.impl.IrFunctionExpressionImpl.accept(IrFunctionExpressionImpl.kt:23)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
at org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression.transformChildren(IrFunctionAccessExpression.kt:48)
这是我的依赖项
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.compose.ui:ui:1.0.0-beta06"
implementation "androidx.compose.material:material:1.0.0-beta06"
implementation "androidx.compose.ui:ui-tooling:1.0.0-beta06"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.0-alpha08'
implementation "androidx.navigation:navigation-compose:2.4.0-alpha01"
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.0-beta06"
Jetpack compose 过去在 Artic Fox Canary 上对我来说运行良好,但是当我在 Artic Fox Beta 1 上构建项目时,出现此错误。
将所有 compose 库更新为 beta07
:
implementation "androidx.compose.ui:ui:1.0.0-beta07"
implementation "androidx.compose.material:material:1.0.0-beta07"
implementation "androidx.compose.ui:ui-tooling:1.0.0-beta07"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.0-beta07"
implementation "androidx.navigation:navigation-compose:2.4.0-alpha01"
最好使用类似的东西:
ext {
compose_version = '1.0.0-beta07'
}
然后:
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
//...
compose 编译器存在问题。仅仅更新 compose 库是不够的,编译器也需要至少更新到 beta07。这很容易被忽略,因为它不在依赖项列表中,并且在 Android Studio 中没有高亮显示(目前)。
composeOptions {
kotlinCompilerExtensionVersion "1.0.0-rc01"
}
我在构建项目时遇到此错误
java.lang.IllegalStateException: function = <anonymous>, count = 4, index = 4
at androidx.compose.compiler.plugins.kotlin.lower.ComposerLambdaMemoization.wrapFunctionExpression(ComposerLambdaMemoization.kt:697)
at androidx.compose.compiler.plugins.kotlin.lower.ComposerLambdaMemoization.visitComposableFunctionExpression(ComposerLambdaMemoization.kt:544)
at androidx.compose.compiler.plugins.kotlin.lower.ComposerLambdaMemoization.visitFunctionExpression(ComposerLambdaMemoization.kt:608)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFunctionExpression(IrElementTransformerVoid.kt:235)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFunctionExpression(IrElementTransformerVoid.kt:24)
at org.jetbrains.kotlin.ir.expressions.impl.IrFunctionExpressionImpl.accept(IrFunctionExpressionImpl.kt:23)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
at org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression.transformChildren(IrFunctionAccessExpression.kt:48)
这是我的依赖项
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.compose.ui:ui:1.0.0-beta06"
implementation "androidx.compose.material:material:1.0.0-beta06"
implementation "androidx.compose.ui:ui-tooling:1.0.0-beta06"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.0-alpha08'
implementation "androidx.navigation:navigation-compose:2.4.0-alpha01"
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.0-beta06"
Jetpack compose 过去在 Artic Fox Canary 上对我来说运行良好,但是当我在 Artic Fox Beta 1 上构建项目时,出现此错误。
将所有 compose 库更新为 beta07
:
implementation "androidx.compose.ui:ui:1.0.0-beta07"
implementation "androidx.compose.material:material:1.0.0-beta07"
implementation "androidx.compose.ui:ui-tooling:1.0.0-beta07"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.0-beta07"
implementation "androidx.navigation:navigation-compose:2.4.0-alpha01"
最好使用类似的东西:
ext {
compose_version = '1.0.0-beta07'
}
然后:
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
//...
compose 编译器存在问题。仅仅更新 compose 库是不够的,编译器也需要至少更新到 beta07。这很容易被忽略,因为它不在依赖项列表中,并且在 Android Studio 中没有高亮显示(目前)。
composeOptions {
kotlinCompilerExtensionVersion "1.0.0-rc01"
}