当前位置: 首页 > news >正文

解决Compose编译报错问题 couldn‘t find inline method Landroidx/compose/...

报错如下

在这里插入图片描述

报错日志

Caused by: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call: CALL 'public final fun Box$default (modifier: androidx.compose.ui.Modifier?, contentAlignment: androidx.compose.ui.Alignment?, propagateMinConstraints: kotlin.Boolean, content: @[Composable] @[ExtensionFunctionType] kotlin.Function1<androidx.compose.foundation.layout.BoxScope, kotlin.Unit>, $mask0: kotlin.Int, $handler: kotlin.Any?): kotlin.Unit [inline] declared in androidx.compose.foundation.layout.BoxKt' type=kotlin.Unit origin=DEFAULT_DISPATCH_CALL
Method: null
File is unknown
The root cause java.lang.IllegalStateException was thrown at: org.jetbrains.kotlin.codegen.inline.SourceCompilerForInlineKt.getMethodNode(SourceCompilerForInline.kt:118)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:67)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrInlineCodegen.genInlineCall(IrInlineCodegen.kt:159)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrInlineCallGenerator.genCall(IrInlineCallGenerator.kt:31)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:659)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:136)
	at org.jetbrains.kotlin.ir.expressions.IrCall.accept(IrCall.kt:26)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitStatementContainer(ExpressionCodegen.kt:594)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:599)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:136)
	at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBlockBody.kt:25)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.generate(ExpressionCodegen.kt:251)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.doGenerate(FunctionCodegen.kt:122)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:47)
	... 80 more
Caused by: java.lang.IllegalStateException: couldn't find inline method Landroidx/compose/foundation/layout/BoxKt;.Box$default(Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
	at org.jetbrains.kotlin.codegen.inline.SourceCompilerForInlineKt.getMethodNode(SourceCompilerForInline.kt:118)
	at org.jetbrains.kotlin.codegen.inline.SourceCompilerForInlineKt.loadCompiledInlineFunction(SourceCompilerForInline.kt:96)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrSourceCompilerForInline.compileInlineFunction(IrSourceCompilerForInline.kt:91)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.compileInline(InlineCodegen.kt:45)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:53)
	... 92 more

Errors were stored into /Users/mac/Documents/code/wordtools/.gradle/kotlin/errors/errors-1743004824812.log

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':HwUserCenterLib:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Internal compiler error. See log for more details

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

问题分析

一开始我认为是我在用Compose组件Box时导包不对,结果不是。原因是我创建了HwUserCenterLib安卓库中没有添加如下配置,导致库在编译Compose时编译报错。

解决方案

在库的build.gradle中找到android闭包内添加如下配置即可

 buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.1"
    }

相关文章:

  • arm对应hex_ASCII与HEX对照转换表
  • 程序化广告行业(34/89):移动端特色广告与创意策略探秘
  • Uncert-CoT: 计算不确定性判断是否启用CoT
  • Slidev使用(一)安装
  • MySQL的sql语句后/G是什么作用?
  • Mysql增删改查
  • 怎样实现CAN数据的接收和发送?
  • 基于Python的3D贴图制作技术研究与实践
  • 数据库基础知识点(系列五)
  • 深入了解 Git Merge:用法、类型与合并冲突处理
  • GPT Researcher 的win docker安装攻略
  • Postman 下载文件指南:如何请求 Excel/PDF 文件?
  • 递归、搜索与回溯第四讲:floodfill算法
  • ​macro-F1(宏平均F1)​和micro-F1(微平均F1)
  • 在kali linux中配置hive(mysql元数据库)
  • 现阶段高校的人工智能方案培训如何?
  • MVC基础概念及相应代码示例
  • Nextjs15 - middleware的使用
  • LeetCode算法题(Go语言实现)_11
  • (每日一道算法题) K 个一组翻转链表
  • 习近平向中国人民解放军仪仗队致意
  • 新华每日电讯:给“男性妇科病论文”开一剂复方药
  • 中华人民共和国和俄罗斯联邦关于进一步加强合作维护国际法权威的联合声明
  • 两部门发布山洪灾害气象预警:北京西部、河北西部等局地山洪可能性较大
  • 昆廷·斯金纳:作为“独立自主”的自由
  • 金融监管总局将推出8项增量政策:涉房地产金融、险资入市、稳外贸等