org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: F:/KotlinProject/CookDemo1/theme1/src/main/java/com/scode/theme1/MaterialTheme.kt
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:49)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:241)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:236)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:68)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:55)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:41)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:43)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.invokeCodegen(JvmIrCodegenFactory.kt:312)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.runCodegen(KotlinToJVMBytecodeCompiler.kt:348)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:123)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:167)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:101)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:47)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:485)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:131)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:424)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:360)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:242)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:98)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:625)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1746)
at jdk.internal.reflect.GeneratedMethodAccessor104.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.RuntimeException: Exception while generating code for:
FUN name:ComposeCookBookMaterial3Theme visibility:public modality:FINAL <> (darkTheme:kotlin.Boolean, colorPallet:com.scode.theme.ColorPallet, content:@[Composable] kotlin.Function0
annotations:
Composable
VALUE_PARAMETER name:darkTheme index:0 type:kotlin.Boolean
EXPRESSION_BODY
ERROR_EXPR 'Default Stub' type=kotlin.Boolean
VALUE_PARAMETER name:colorPallet index:1 type:com.scode.theme.ColorPallet
EXPRESSION_BODY
ERROR_EXPR 'Default Stub' type=com.scode.theme.ColorPallet
VALUE_PARAMETER name:content index:2 type:@[Composable] kotlin.Function0
BLOCK_BODY
VAR name:context type:android.content.Context [val]
CALL 'public final fun
$this: TYPE_OP type=androidx.compose.runtime.CompositionLocal
CALL 'public final fun
VAR name:colors type:androidx.compose.material3.ColorScheme [val]
BLOCK type=androidx.compose.material3.ColorScheme origin=WHEN
VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:com.scode.theme.ColorPallet [val]
GET_VAR 'colorPallet: com.scode.theme.ColorPallet declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=com.scode.theme.ColorPallet origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp0 type:kotlin.Int [val]
CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in kotlin.IntArray' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD ENUM_MAPPINGS_FOR_WHEN name:$EnumSwitchMapping$0 type:kotlin.IntArray visibility:public [final,static]' type=kotlin.IntArray origin=null
index: CALL 'public final fun
$this: GET_VAR 'val tmp0_subject: com.scode.theme.ColorPallet [val] declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=com.scode.theme.ColorPallet origin=null
WHEN type=androidx.compose.material3.ColorScheme origin=WHEN
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null
arg0: GET_VAR 'val tmp0: kotlin.Int [val] declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=kotlin.Int origin=null
arg1: CONST Int type=kotlin.Int value=1
then: WHEN type=androidx.compose.material3.ColorScheme origin=IF
BRANCH
if: GET_VAR 'darkTheme: kotlin.Boolean declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=kotlin.Boolean origin=null
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:DarkGreenColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:LightGreenColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null
arg0: GET_VAR 'val tmp0: kotlin.Int [val] declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=kotlin.Int origin=null
arg1: CONST Int type=kotlin.Int value=2
then: WHEN type=androidx.compose.material3.ColorScheme origin=IF
BRANCH
if: GET_VAR 'darkTheme: kotlin.Boolean declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=kotlin.Boolean origin=null
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:DarkPurpleColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:LightPurpleColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null
arg0: GET_VAR 'val tmp0: kotlin.Int [val] declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=kotlin.Int origin=null
arg1: CONST Int type=kotlin.Int value=3
then: WHEN type=androidx.compose.material3.ColorScheme origin=IF
BRANCH
if: GET_VAR 'darkTheme: kotlin.Boolean declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=kotlin.Boolean origin=null
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:DarkOrangeColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:LightOrangeColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null
arg0: GET_VAR 'val tmp0: kotlin.Int [val] declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=kotlin.Int origin=null
arg1: CONST Int type=kotlin.Int value=4
then: WHEN type=androidx.compose.material3.ColorScheme origin=IF
BRANCH
if: GET_VAR 'darkTheme: kotlin.Boolean declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=kotlin.Boolean origin=null
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:DarkBlueColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:LightBlueColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
WHEN type=androidx.compose.material3.ColorScheme origin=IF
BRANCH
if: GET_VAR 'darkTheme: kotlin.Boolean declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=kotlin.Boolean origin=null
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:DarkGreenColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=androidx.compose.material3.ColorScheme origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:LightGreenColorPalette type:androidx.compose.material3.ColorScheme visibility:private [final,static]' type=androidx.compose.material3.ColorScheme origin=null
CALL 'public final fun MaterialTheme$default (colorScheme: androidx.compose.material3.ColorScheme?, shapes: androidx.compose.material3.Shapes?, typography: androidx.compose.material3.Typography?, content: @[Composable] kotlin.Function0
colorScheme: GET_VAR 'val colors: androidx.compose.material3.ColorScheme [val] declared in com.scode.theme1.MaterialThemeKt.ComposeCookBookMaterial3Theme' type=androidx.compose.material3.ColorScheme origin=null
shapes: COMPOSITE type=androidx.compose.material3.Shapes? origin=DEFAULT_VALUE
CONST Null type=androidx.compose.material3.Shapes? value=null
typography: COMPOSITE type=androidx.compose.material3.Typography? origin=DEFAULT_VALUE
CONST Null type=androidx.compose.material3.Typography? value=null
content: GET_VAR 'content: @[Composable] kotlin.Function0
$mask0: CONST Int type=kotlin.Int value=6
$handler: CONST Null type=kotlin.Any? value=null
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:49)
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate$default(FunctionCodegen.kt:41)
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethodNode(ClassCodegen.kt:408)
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethod(ClassCodegen.kt:425)
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generate(ClassCodegen.kt:168)
at org.jetbrains.kotlin.backend.jvm.FileCodegen.lower(JvmPhases.kt:44)
at org.jetbrains.kotlin.backend.common.phaser.FileLoweringPhaseAdapter.invoke(PhaseBuilders.kt:120)
at org.jetbrains.kotlin.backend.common.phaser.FileLoweringPhaseAdapter.invoke(PhaseBuilders.kt:116)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:65)
... 40 more
Caused by: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call: CALL 'public final fun
解决
moudle中的build.grade中添加
buildFeatures.compose = true composeOptions.kotlinCompilerExtensionVersion = "1.4.2"
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "com.scode.theme1"
compileSdk = 33
defaultConfig {
minSdk = 21
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
//添加以下配置
buildFeatures.compose = true
composeOptions.kotlinCompilerExtensionVersion = "1.4.2"
}
文章来源
发表评论