am introducing `compose` into new project but I ca...
# compose
m
am introducing
compose
into new project but I can’t run it. error:
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
I have fragment with
ComposeView
and am just calling
setContent
on it any help? compose version 1.0.2 compose build feature is enabled
Copy code
composeOptions {
    kotlinCompilerExtensionVersion = "1.0.2"
    kotlinCompilerVersion = "1.5.21"
}
z
kotlinCompilerVersion
should not be required. You have the compose feature flag enabled as well?
m
I added
kotlinCompilerVersion
just in case it will make it work 😄. yes I have feature enabled
I also tried 1.0.1 and 1.1.0-alpha04 and always the same error
z
Is there any more to that error message? Could be a legit compiler bug
m
there is just a call stack
I will copy paste everything
error calling
setContent
which call`modifier.size(),` which calls…. etc. and it comes to a method that doesn’t exist -> not generated
z
can you paste the actual error and stack trace?
m
am not getting error any more for some reason
now am running the app, install successful but app doesn’t start
when I click app icon it shows
App not installeld
getting error again
Copy code
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: HomeFragment.kt
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
	at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
	at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235)
	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.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.doGenerateFilesInternal(JvmIrCodegenFactory.kt:191)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:60)
	at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:618)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:211)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:154)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:90)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:386)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:110)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:303)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:121)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:74)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1659)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
	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(Native Method)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.RuntimeException: Exception while generating code for:
FUN name:onCreateView visibility:public modality:OPEN <> ($HomeFragment, inflater:android.view.LayoutInflater, container:android.view.ViewGroup?, savedInstanceState:android.os.Bundle?) returnType:android.view.View
  overridden:
    public open fun onCreateView (p0: @[EnhancedNullability] android.view.LayoutInflater, p1: @[EnhancedNullability] android.view.ViewGroup?, p2: @[EnhancedNullability] android.os.Bundle?): @[EnhancedNullability] android.view.View? declared in androidx.fragment.app.Fragment
  $this: VALUE_PARAMETER name:<this> type:HomeFragment
  VALUE_PARAMETER name:inflater index:0 type:android.view.LayoutInflater
  VALUE_PARAMETER name:container index:1 type:android.view.ViewGroup?
  VALUE_PARAMETER name:savedInstanceState index:2 type:android.os.Bundle?
  BLOCK_BODY
    RETURN type=kotlin.Nothing from='public open fun onCreateView (inflater: android.view.LayoutInflater, container: android.view.ViewGroup?, savedInstanceState: android.os.Bundle?): android.view.View declared in HomeFragment'
      CALL 'public final fun apply <T> (block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.apply, kotlin.Unit>): T of kotlin.StandardKt.apply [inline] declared in kotlin.StandardKt' type=androidx.compose.ui.platform.ComposeView origin=null
        <T>: androidx.compose.ui.platform.ComposeView
        $receiver: CONSTRUCTOR_CALL 'public constructor <init> (context: android.content.Context, attrs: android.util.AttributeSet?, defStyleAttr: <http://kotlin.Int|kotlin.Int>, $mask0: <http://kotlin.Int|kotlin.Int>, $marker: kotlin.jvm.internal.DefaultConstructorMarker?) declared in androidx.compose.ui.platform.ComposeView' type=androidx.compose.ui.platform.ComposeView origin=DEFAULT_DISPATCH_CALL
          context: BLOCK type=android.content.Context origin=null
            VAR IR_TEMPORARY_VARIABLE name:tmp0 type:kotlin.Any? [val]
              CALL 'public final fun requireContext (): @[EnhancedNullability] android.content.Context [fake_override] declared in HomeFragment' type=@[EnhancedNullability] android.content.Context origin=null
                $this: GET_VAR '<this>: HomeFragment declared in HomeFragment.onCreateView' type=HomeFragment origin=null
            COMPOSITE type=android.content.Context origin=null
              CALL 'public final fun checkNotNullExpressionValue (value: kotlin.Any?, expression: kotlin.String): kotlin.Unit declared in kotlin.jvm.internal.Intrinsics' type=kotlin.Unit origin=null
                value: GET_VAR 'val tmp0: kotlin.Any? [val] declared in HomeFragment.onCreateView' type=kotlin.Any? origin=null
                expression: CONST String type=kotlin.String value="requireContext()"
              GET_VAR 'val tmp0: kotlin.Any? [val] declared in HomeFragment.onCreateView' type=kotlin.Any? origin=null
          attrs: COMPOSITE type=android.util.AttributeSet? origin=DEFAULT_VALUE
            CONST Null type=android.util.AttributeSet? value=null
          defStyleAttr: COMPOSITE type=<http://kotlin.Int|kotlin.Int> origin=DEFAULT_VALUE
            CONST Int type=<http://kotlin.Int|kotlin.Int> value=0
          $mask0: CONST Int type=<http://kotlin.Int|kotlin.Int> value=6
          $marker: CONST Null type=kotlin.jvm.internal.DefaultConstructorMarker? value=null
        block: BLOCK type=@[ExtensionFunctionType] kotlin.Function1<androidx.compose.ui.platform.ComposeView, kotlin.Unit> origin=LAMBDA
          COMPOSITE type=kotlin.Unit origin=null
          FUNCTION_REFERENCE 'private final fun onCreateView$lambda-0 (): kotlin.Unit declared in HomeFragment' type=@[ExtensionFunctionType] kotlin.Function1<androidx.compose.ui.platform.ComposeView, kotlin.Unit> origin=LAMBDA reflectionTarget=null

	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate$default(FunctionCodegen.kt:43)
	at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethodNode(ClassCodegen.kt:349)
	at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethod(ClassCodegen.kt:366)
	at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generate(ClassCodegen.kt:133)
	at org.jetbrains.kotlin.backend.jvm.JvmLowerKt$codegenPhase$1$1.lower(JvmLower.kt:304)
	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)
	... 44 more
Copy code
Caused by: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call 'apply' into
public open fun onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup?, savedInstanceState: android.os.Bundle?): android.view.View defined in HomeFragment
<no source>
Cause: apply (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;:
  @Lkotlin/internal/InlineOnly;() // invisible
   L0
    LDC 0
    ISTORE 2
   L1
    LINENUMBER 80 L1
    ICONST_0
    ISTORE 3
   L2
    LINENUMBER 83 L2
    ALOAD 1
    ALOAD 0
    INVOKEINTERFACE kotlin/jvm/functions/Function1.invoke (Ljava/lang/Object;)Ljava/lang/Object; (itf)
    POP
   L3
    LINENUMBER 84 L3
    ALOAD 0
    ARETURN
   L4
    LOCALVARIABLE $this$apply Ljava/lang/Object; L0 L4 0
    LOCALVARIABLE block Lkotlin/jvm/functions/Function1; L0 L4 1
    LOCALVARIABLE $i$f$apply I L1 L4 2
    MAXSTACK = 2
    MAXLOCALS = 4

File is unknown
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.throwCompilationException(InlineCodegen.kt:101)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:141)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrInlineCodegen.genInlineCall(IrInlineCodegen.kt:148)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrInlineCallGenerator$DefaultImpls.genCall(IrInlineCallGenerator.kt:29)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrInlineCodegen.genCall(IrInlineCodegen.kt:35)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:500)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitReturn(ExpressionCodegen.kt:945)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitReturn(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl.accept(IrReturnImpl.kt:34)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitStatementContainer(ExpressionCodegen.kt:447)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:451)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBody.kt:54)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.generate(ExpressionCodegen.kt:247)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.doGenerate(FunctionCodegen.kt:122)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:48)
	... 53 more
Caused by: java.lang.RuntimeException: Exception while generating code for:
FUN LOCAL_FUNCTION_FOR_LAMBDA name:onCreateView$lambda-0 visibility:private modality:FINAL <> ($receiver:androidx.compose.ui.platform.ComposeView) returnType:kotlin.Unit
  $receiver: VALUE_PARAMETER name:$this$apply type:androidx.compose.ui.platform.ComposeView
  BLOCK_BODY
    VAR name:$i$a$-apply-HomeFragment$onCreateView$1 type:<http://kotlin.Int|kotlin.Int> [val]
      CONST Int type=<http://kotlin.Int|kotlin.Int> value=0
    CALL 'public final fun setContent (content: @[Composable] kotlin.Function0<kotlin.Unit>): kotlin.Unit declared in androidx.compose.ui.platform.ComposeView' type=kotlin.Unit origin=null
      $this: GET_VAR '$this$apply: androidx.compose.ui.platform.ComposeView declared in HomeFragment.onCreateView$lambda-0' type=androidx.compose.ui.platform.ComposeView origin=null
      content: BLOCK type=HomeFragment.onCreateView$lambda-0.<no name provided> origin=null
        CLASS LAMBDA_IMPL CLASS name:<no name provided> modality:FINAL visibility:public/*package*/ superTypes:[kotlin.jvm.internal.Lambda; kotlin.jvm.functions.Function0<kotlin.Unit>]
          $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:HomeFragment.onCreateView$lambda-0.<no name provided>
          CONSTRUCTOR GENERATED_MEMBER_IN_CALLABLE_REFERENCE visibility:public/*package*/ <> () returnType:HomeFragment.onCreateView$lambda-0.<no name provided> [primary]
            BLOCK_BODY
              DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (arity: <http://kotlin.Int|kotlin.Int>) declared in kotlin.jvm.internal.Lambda'
                arity: CONST Int type=<http://kotlin.Int|kotlin.Int> value=0
              BLOCK type=kotlin.Unit origin=null
          FUN name:invoke visibility:public modality:FINAL <> ($this:HomeFragment.onCreateView$lambda-0.<no name provided>) returnType:kotlin.Unit
            $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:HomeFragment.onCreateView$lambda-0.<no name provided>
            BLOCK_BODY
              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: <http://kotlin.Int|kotlin.Int>, $handler: kotlin.Any?): kotlin.Unit [inline] declared in androidx.compose.foundation.layout.BoxKt' type=kotlin.Unit origin=DEFAULT_DISPATCH_CALL
                modifier: CALL 'public final fun fillMaxSize$default (fraction: kotlin.Float, $mask0: <http://kotlin.Int|kotlin.Int>, $handler: kotlin.Any?): androidx.compose.ui.Modifier declared in androidx.compose.foundation.layout.SizeKt' type=androidx.compose.ui.Modifier origin=DEFAULT_DISPATCH_CALL
                  $receiver: GET_FIELD 'FIELD FIELD_FOR_OBJECT_INSTANCE name:Companion type:androidx.compose.ui.Modifier.Companion visibility:public [final,static]' type=androidx.compose.ui.Modifier.Companion origin=null
                  fraction: COMPOSITE type=kotlin.Float origin=DEFAULT_VALUE
                    CONST Float type=kotlin.Float value=0.0
                  $mask0: CONST Int type=<http://kotlin.Int|kotlin.Int> value=1
                  $handler: CONST Null type=kotlin.Any? value=null
                contentAlignment: COMPOSITE type=androidx.compose.ui.Alignment? origin=DEFAULT_VALUE
                  CONST Null type=androidx.compose.ui.Alignment? value=null
                propagateMinConstraints: COMPOSITE type=kotlin.Boolean origin=DEFAULT_VALUE
                  CONST Boolean type=kotlin.Boolean value=false
                content: BLOCK type=@[ExtensionFunctionType] kotlin.Function1<androidx.compose.foundation.layout.BoxScope, kotlin.Unit> origin=LAMBDA
                  COMPOSITE type=kotlin.Unit origin=null
                  FUNCTION_REFERENCE 'private final fun invoke$lambda-0 (): kotlin.Unit declared in HomeFragment.onCreateView$lambda-0.<no name provided>' type=@[ExtensionFunctionType] kotlin.Function1<androidx.compose.foundation.layout.BoxScope, kotlin.Unit> origin=LAMBDA reflectionTarget=null
                $mask0: CONST Int type=<http://kotlin.Int|kotlin.Int> value=6
                $handler: CONST Null type=kotlin.Any? value=null
          FIELD FIELD_FOR_STATIC_CALLABLE_REFERENCE_INSTANCE name:INSTANCE type:HomeFragment.onCreateView$lambda-0.<no name provided> visibility:public [final,static]
          FUN CLASS_STATIC_INITIALIZER name:<clinit> visibility:public/*package*/ modality:FINAL <> () returnType:kotlin.Unit
            BLOCK_BODY
              SET_FIELD 'FIELD FIELD_FOR_STATIC_CALLABLE_REFERENCE_INSTANCE name:INSTANCE type:HomeFragment.onCreateView$lambda-0.<no name provided> visibility:public [final,static]' type=kotlin.Unit origin=INITIALIZE_FIELD
                value: CONSTRUCTOR_CALL 'public/*package*/ constructor <init> () [primary] declared in HomeFragment.onCreateView$lambda-0.<no name provided>' type=HomeFragment.onCreateView$lambda-0.<no name provided> origin=null
          FUN BRIDGE name:invoke visibility:public modality:OPEN <> ($this:HomeFragment.onCreateView$lambda-0.<no name provided>) returnType:kotlin.Any?
            $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:HomeFragment.onCreateView$lambda-0.<no name provided>
            EXPRESSION_BODY
              CALL 'public final fun invoke (): kotlin.Unit declared in HomeFragment.onCreateView$lambda-0.<no name provided>' type=kotlin.Unit origin=BRIDGE_DELEGATION
                $this: GET_VAR '<this>: HomeFragment.onCreateView$lambda-0.<no name provided> declared in HomeFragment.onCreateView$lambda-0.<no name provided>.invoke' type=HomeFragment.onCreateView$lambda-0.<no name provided> origin=null
        GET_FIELD 'FIELD FIELD_FOR_STATIC_CALLABLE_REFERENCE_INSTANCE name:INSTANCE type:HomeFragment.onCreateView$lambda-0.<no name provided> visibility:public [final,static]' type=HomeFragment.onCreateView$lambda-0.<no name provided> origin=null

	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrSourceCompilerForInline.generateLambdaBody(IrSourceCompilerForInline.kt:105)
	at org.jetbrains.kotlin.codegen.inline.ExpressionLambda.generateLambdaBody(LambdaInfo.kt:81)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.generateClosuresBodies(InlineCodegen.kt:351)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.inlineCall(InlineCodegen.kt:212)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:135)
	... 69 more
Copy code
Caused by: java.lang.RuntimeException: Exception while generating code for:
FUN name:invoke visibility:public modality:FINAL <> ($this:HomeFragment.onCreateView$lambda-0.<no name provided>) returnType:kotlin.Unit
  $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:HomeFragment.onCreateView$lambda-0.<no name provided>
  BLOCK_BODY
    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: <http://kotlin.Int|kotlin.Int>, $handler: kotlin.Any?): kotlin.Unit [inline] declared in androidx.compose.foundation.layout.BoxKt' type=kotlin.Unit origin=DEFAULT_DISPATCH_CALL
      modifier: CALL 'public final fun fillMaxSize$default (fraction: kotlin.Float, $mask0: <http://kotlin.Int|kotlin.Int>, $handler: kotlin.Any?): androidx.compose.ui.Modifier declared in androidx.compose.foundation.layout.SizeKt' type=androidx.compose.ui.Modifier origin=DEFAULT_DISPATCH_CALL
        $receiver: GET_FIELD 'FIELD FIELD_FOR_OBJECT_INSTANCE name:Companion type:androidx.compose.ui.Modifier.Companion visibility:public [final,static]' type=androidx.compose.ui.Modifier.Companion origin=null
        fraction: COMPOSITE type=kotlin.Float origin=DEFAULT_VALUE
          CONST Float type=kotlin.Float value=0.0
        $mask0: CONST Int type=<http://kotlin.Int|kotlin.Int> value=1
        $handler: CONST Null type=kotlin.Any? value=null
      contentAlignment: COMPOSITE type=androidx.compose.ui.Alignment? origin=DEFAULT_VALUE
        CONST Null type=androidx.compose.ui.Alignment? value=null
      propagateMinConstraints: COMPOSITE type=kotlin.Boolean origin=DEFAULT_VALUE
        CONST Boolean type=kotlin.Boolean value=false
      content: BLOCK type=@[ExtensionFunctionType] kotlin.Function1<androidx.compose.foundation.layout.BoxScope, kotlin.Unit> origin=LAMBDA
        COMPOSITE type=kotlin.Unit origin=null
        FUNCTION_REFERENCE 'private final fun invoke$lambda-0 (): kotlin.Unit declared in HomeFragment.onCreateView$lambda-0.<no name provided>' type=@[ExtensionFunctionType] kotlin.Function1<androidx.compose.foundation.layout.BoxScope, kotlin.Unit> origin=LAMBDA reflectionTarget=null
      $mask0: CONST Int type=<http://kotlin.Int|kotlin.Int> value=6
      $handler: CONST Null type=kotlin.Any? value=null

	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate$default(FunctionCodegen.kt:43)
	at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethodNode(ClassCodegen.kt:349)
	at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethod(ClassCodegen.kt:366)
	at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generate(ClassCodegen.kt:133)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitClass(ExpressionCodegen.kt:910)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitClass(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:55)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitStatementContainer(ExpressionCodegen.kt:447)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitContainerExpression(ExpressionCodegen.kt:456)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitContainerExpression(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitBlock(IrElementVisitor.kt:60)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlock(ExpressionCodegen.kt:393)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlock(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl.accept(IrBlockImpl.kt:48)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.gen(ExpressionCodegen.kt:222)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrCallGenerator$DefaultImpls.genValueAndPut(IrCallGenerator.kt:47)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrCallGenerator$DefaultCallGenerator.genValueAndPut(IrCallGenerator.kt:50)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:491)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitStatementContainer(ExpressionCodegen.kt:447)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:451)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBody.kt:54)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.generate(ExpressionCodegen.kt:247)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.doGenerate(FunctionCodegen.kt:122)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:48)
	... 74 more
Caused by: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call 'Box$default' into
public final fun invoke(): kotlin.Unit defined in HomeFragment.`onCreateView$lambda-0`.<no name provided>
<no source>
Cause: Not generated
File is unknown
The root cause java.lang.IllegalStateException was thrown at: org.jetbrains.kotlin.codegen.inline.InlineCodegen$Companion.getCompiledMethodNodeInner(InlineCodegen.kt:578)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.throwCompilationException(InlineCodegen.kt:101)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:141)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrInlineCodegen.genInlineCall(IrInlineCodegen.kt:148)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrInlineCallGenerator$DefaultImpls.genCall(IrInlineCallGenerator.kt:29)
	at org.jetbrains.kotlin.backend.jvm.codegen.IrInlineCodegen.genCall(IrInlineCodegen.kt:35)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:500)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitStatementContainer(ExpressionCodegen.kt:447)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:451)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:139)
	at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBody.kt:54)
	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.generate(ExpressionCodegen.kt:247)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.doGenerate(FunctionCodegen.kt:122)
	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:48)
	... 101 more
Caused by: java.lang.IllegalStateException: Couldn't obtain compiled function body for IrBasedSimpleFunctionDescriptor: FUN FUNCTION_FOR_DEFAULT_PARAMETER name:Box$default visibility:public modality:FINAL <> (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:<http://kotlin.Int|kotlin.Int>, $handler:kotlin.Any?) returnType:kotlin.Unit [inline]
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen$Companion.getCompiledMethodNodeInner(InlineCodegen.kt:578)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen$Companion.access$getCompiledMethodNodeInner(InlineCodegen.kt:542)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.createInlineMethodNode$backend(InlineCodegen.kt:535)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:134)
	... 114 more
it’s a bit long
w
I've had this issue , I had to just use buildFeatures {compose true} and also in libraries where there is compose used and it resolved it but you say buildFeatures compose is true
m
doesn’t work for me
z
can you post your implementation of
onCreateView
?
m
Copy code
return ComposeView(requireContext).apply {
    setContent {}
}
empty
setContent
. it’s the same if I have something inside of it. doesn’t matter how I do it this is error I get
I’ve also tried having
ComposeView
inside fragment
XML
layout but still the same
z
What if you get rid of the apply and assign the view to a variable before turning it?
m
just tried, still getting same error
it’s the same if I do
setContent
inside activity’s
onCreate
I tried to assign the
ComposeView
to a variable, set it up and return it from
onCreateView
+ clean/rebuild and I was able to run the app. but now there is runtime crash
No virtual method setContent
and if I use some composable,
Box
for example, inside of
setContent
I get above compile error
activity
onCreate
and
setContent
with empty body gives that compile error too
z
can you post your build.gradle?
m
app or project level?
Copy code
plugins {
    id("com.android.application")
    id("kotlin-android")
    id("kotlin-parcelize")
    id("androidx.navigation.safeargs.kotlin")
    id("kotlin-kapt")
    id("realm-android")
    id("com.google.gms.google-services")
    id("com.google.firebase.crashlytics")
    id("plugins.ktlint")
}

android {
    compileSdkVersion(Configurations.Android.COMPILE_SDK)

    defaultConfig {
        applicationId = Configurations.App.ID

        minSdkVersion(Configurations.Android.MIN_SDK)
        targetSdkVersion(Configurations.Android.TARGET_SDK)

        versionCode = Configurations.App.VERSION_CODE
        versionName = Configurations.App.VERSION_NAME

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

        multiDexEnabled = true

        vectorDrawables.useSupportLibrary = true
    }

    buildFeatures {
        viewBinding = true
        compose = true
    }

    compileOptions {
        sourceCompatibility("1.8")
        targetCompatibility("1.8")
    }

    kotlinOptions {
        useIR = true
        jvmTarget = "1.8"
        freeCompilerArgs =
            freeCompilerArgs + "-Xuse-experimental=kotlin.contracts.ExperimentalContracts"
    }

    composeOptions {
        kotlinCompilerExtensionVersion = "1.0.2"
    }
}

dependencies {
    implementation("androidx.activity:activity-compose:1.3.1")
    implementation("androidx.compose.ui:ui:1.0.2")
    implementation("androidx.compose.runtime:runtime:1.0.2")
    implementation("androidx.compose.compiler:compiler:1.0.2")
    implementation("androidx.compose.material:material:1.0.2")
    implementation("androidx.compose.animation:animation:1.0.2")
    implementation("androidx.compose.ui:ui-tooling:1.0.2")
    implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0-beta01")

    // Kotlin
    implementation(Libs.Kotlin.stdlib)
}

apply(plugin = "com.google.gms.google-services")
that’s app build.gradle.kts I omitted everything not related to this, can’t expose much
and this is project lvl build.gradle.kts
Copy code
buildscript {

    repositories {
        mavenCentral()
        google()
        jcenter()
    }

    dependencies {
        classpath(Libs.Kotlin.Plugin.gradle)
        classpath(Libs.Android.Plugin.navigation)
        classpath(Libs.Android.Plugin.gradle)
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven(Configurations.Maven.JITPACK)
        maven(Configurations.Maven.AWS)
        maven(Configurations.Maven.ZENDESK)
    }
}

tasks.register("clean", Delete::class) {
    delete(rootProject.buildDir)
}
you don’t see
Copy code
plugins {
    id 'org.jetbrains.kotlin:android' version '1.5.21'
}
in there because now it gives me problems too. but it used to work and I was getting same error
either this compile error or this runtime crash
Copy code
java.lang.NoSuchMethodError: No virtual method setContent(Lkotlin/jvm/functions/Function0;)V in class Landroidx/compose/ui/platform/ComposeView; or its super classes (declaration of 'androidx.compose.ui.platform.ComposeView' appears in
z
It looks like the compose compiler plugin isn’t processing your module for some reason, but i’m not sure why – that config looks good to me.
m
thank you very much
I will file a bug
it doesn’t recognise
app
module or other modules? it’s multi module app @Zach Klippenstein (he/him) [MOD]
z
it should work fine with app or library modules
m
thanks
I finally made it work! I don’t know how and what made it work. to me it seems that I was doing same thing over and over again but it finally worked. omfg. thank you very much for your help, I really appreciate it