• c

    codeslubber

    2 years ago
    We have to put
    @Composable
    on onClick lambdas now?? ugh…
    c
    r
    27 replies
    Copy to Clipboard
  • c

    codeslubber

    2 years ago
    So I did a stepper in Compose and followed an example where I had the state in the Composable method, then called a stepper function and passed it the state. Worked in 03, does not compile in 04, tells me I cannot mutate a val.
    @Composable
    fun MeasureQuestionView() {
        val typography = (MaterialTheme.typography())
    
        val rangeOfValues = 115..125
        val currentValue = state {rangeOfValues.first}
    
        Card(shape = RoundedCornerShape(8.dp)) {
            Column(modifier = Spacing(16.dp)) {
                Text("What was your blood sugar reading?", style = typography.h6)
                numberStepper(currentValue, rangeOfValues, "mg/dL")
            }
        }
    
    }
    
    @Composable
    fun numberStepper(currentValue: State<Int>, range: IntRange, units: String) {
        val typography = (MaterialTheme.typography())
    
        Container(height = 75.dp) {
            Row(Spacing(20.dp)) {
                Button(text = "-", onClick = {
                    if (currentValue.value > range.first) {
                        currentValue.value -= 1
                    }
                })
                Spacer(LayoutWidth(10.dp))
                Text(currentValue.value.toString(), style = typography.h5)
                Spacer(LayoutWidth(10.dp))
                Button(text = "+", onClick = {
                    if (currentValue.value < range.last) currentValue.value += 1
                })
                Spacer(LayoutWidth(10.dp))
                Align(Alignment.CenterLeft){
                    Text(units)
                }
            }
        }
    
    }
    c
    Adam Powell
    6 replies
    Copy to Clipboard
  • zhuinden

    zhuinden

    2 years ago
    e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    Element is unknownThe root cause java.util.NoSuchElementException was thrown at: androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.irComposableExpr(ComposableCallTransformer.kt:1362)
    	at org.jetbrains.kotlin.codegen.CompilationErrorHandler.lambda$static$0(CompilationErrorHandler.java:35)
    	at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm(JvmBackendFacade.kt:93)
    	at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm$default(JvmBackendFacade.kt:64)
    	at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm(JvmBackendFacade.kt:52)
    	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:36)
    	at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.doGenerateFiles(KotlinCodegenFacade.java:47)
    	at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:39)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:638)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:198)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:172)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:56)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:85)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
    	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
    Caused by: java.util.NoSuchElementException: Collection contains no element matching the predicate.
    	at androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.irComposableExpr(ComposableCallTransformer.kt:1362)
    	at androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.visitBlock(ComposableCallTransformer.kt:252)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlock(IrElementTransformerVoid.kt:128)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlock(IrElementTransformerVoid.kt:24)
    	at org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl.accept(IrBlockImpl.kt:52)
    	at org.jetbrains.kotlin.ir.expressions.IrExpression$DefaultImpls.transform(IrExpression.kt:28)
    	at org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase.transform(IrExpressionBase.kt:24)
    	at org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl.transformChildren(IrTypeOperatorCallImpl.kt:75)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:288)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildrenVoid(IrElementTransformerVoid.kt:283)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildren(IrElementTransformerVoid.kt:25)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpression(IrElementTransformerVoid.kt:112)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitTypeOperator(IrElementTransformerVoid.kt:214)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitTypeOperator(IrElementTransformerVoid.kt:215)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitTypeOperator(IrElementTransformerVoid.kt:24)
    	at org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl.accept(IrTypeOperatorCallImpl.kt:68)
    	at org.jetbrains.kotlin.ir.expressions.IrExpression$DefaultImpls.transform(IrExpression.kt:28)
    	at org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase.transform(IrExpressionBase.kt:24)
    	at org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl.transformChildren(IrVariableImpl.kt:93)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:288)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildrenVoid(IrElementTransformerVoid.kt:283)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildren(IrElementTransformerVoid.kt:25)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:46)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitVariable(IrElementTransformerVoid.kt:87)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitVariable(IrElementTransformerVoid.kt:88)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitVariable(IrElementTransformerVoid.kt:24)
    	at org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl.accept(IrVariableImpl.kt:86)
    	at org.jetbrains.kotlin.ir.declarations.IrDeclaration$DefaultImpls.transform(IrDeclaration.kt:42)
    	at org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase.transform(IrDeclarationBase.kt:27)
    	at org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl.transformChildren(IrBlockBodyImpl.kt:49)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:288)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildrenVoid(IrElementTransformerVoid.kt:283)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildren(IrElementTransformerVoid.kt:25)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBody(IrElementTransformerVoid.kt:93)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:99)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:100)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:24)
    	at org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl.accept(IrBlockBodyImpl.kt:40)
    	at org.jetbrains.kotlin.ir.expressions.IrBody$DefaultImpls.transform(IrBody.kt:24)
    	at org.jetbrains.kotlin.ir.expressions.IrBlockBody$DefaultImpls.transform(IrBody.kt)
    	at org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl.transform(IrBlockBodyImpl.kt:26)
    	at org.jetbrains.kotlin.ir.declarations.impl.IrFunctionBase.transformChildren(IrFunctionBase.kt:77)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:288)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildrenVoid(IrElementTransformerVoid.kt:283)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildren(IrElementTransformerVoid.kt:25)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:46)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFunction(IrElementTransformerVoid.kt:55)
    	at androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.visitFunction(ComposableCallTransformer.kt:205)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:58)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:59)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:24)
    	at org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl.accept(IrFunctionImpl.kt:89)
    	at org.jetbrains.kotlin.ir.declarations.IrDeclaration$DefaultImpls.transform(IrDeclaration.kt:42)
    	at org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase.transform(IrDeclarationBase.kt:27)
    	at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.transformChildren(IrFileImpl.kt:71)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:288)
    	at androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.lower(ComposableCallTransformer.kt:197)
    	at org.jetbrains.kotlin.backend.common.LowerKt.lower(Lower.kt:66)
    	at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$makeIrModulePhase$1.invoke(PhaseBuilders.kt:235)
    	at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$makeIrModulePhase$1.invoke(PhaseBuilders.kt:228)
    	at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper$runBody$1.invoke(CompilerPhase.kt:128)
    	at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.downlevel(CompilerPhase.kt:24)
    	at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.runBody(CompilerPhase.kt:127)
    	at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.invoke(CompilerPhase.kt:105)
    	at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
    	at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:42)
    	at org.jetbrains.kotlin.backend.jvm.JvmLower.lower(JvmLower.kt:288)
    	at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm(JvmBackendFacade.kt:91)
    	... 37 more
    
    
    e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    All I did was update this repo: https://github.com/Zhuinden/compose-simple-stack-experiment to dev04 and then remove
    unaryPlus
    from before where it was still there, and boom compilation exception in compiler 🤔
    zhuinden
    2 replies
    Copy to Clipboard
  • c

    codeslubber

    2 years ago
    Finally got my project to compile!! now a nutty thing is happening with my stepper. On first render things look fine: but then when I click + I get this:
    c
    Zach Klippenstein (he/him) [MOD]
    +1
    10 replies
    Copy to Clipboard
  • Ian Warwick

    Ian Warwick

    2 years ago
    I managed to get my playground app working but hitting this now
    e: org.jetbrains.kotlin.util.KotlinFrontEndException: Front-end Internal error: Failed to analyze declaration Mapper
    File being compiled at position: (21,1) in /Users/ian.warwick/Documents/sdev/memset/router/src/main/java/com/citizenwarwick/memset/router/Mapper.kt
    The root cause java.lang.OutOfMemoryError was thrown at: unknown
    	at org.jetbrains.kotlin.resolve
    Wondering if its because I am offline, will try restart maybe some java process holding to much mem?
    Ian Warwick
    camkadev
    3 replies
    Copy to Clipboard
  • camkadev

    camkadev

    2 years ago
    Functions which invoke @Composable functions must be marked with the @Composable annotation
    any workaround to change data (outside Composable) placed inside state?
    camkadev
    Ian Warwick
    +1
    11 replies
    Copy to Clipboard
  • Ian Warwick

    Ian Warwick

    2 years ago
    Not sure what the purpose of
    key
    is?
    for (user in users) {
        key(user.id) { UserPreview(user = user) }
    }
    The docs don't really explain why you would use it 🤔 or I am not reading them properly
    Ian Warwick
    k
    2 replies
    Copy to Clipboard
  • Ian Warwick

    Ian Warwick

    2 years ago
    Should we be using
    ModelList
    in our models? I found it was the only way to detect changes in a list but not sure if its for use in
    @Model
    annotated classes 🤔
    Ian Warwick
    Adam Powell
    10 replies
    Copy to Clipboard
  • amar_1995

    amar_1995

    2 years ago
    I am calling suspend function to retive data from server and then insert that data inside room db. But I am getting this wierd error
    2020-01-30 20:25:18.750 21058-21058/com.amar.modularnewsapp E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.amar.modularnewsapp, PID: 21058
        java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Number.intValue()' on a null object reference
            at com.amar.modularnewsapp.repository.ArticleRepo$$loadMoreData$Continuation.invokeSuspend(Unknown Source:14)
            at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
            at kotlinx.coroutines.ResumeModeKt.resumeUninterceptedMode(ResumeMode.kt:46)
            at kotlinx.coroutines.internal.ScopeCoroutine.afterCompletionInternal(Scopes.kt:32)
            at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:310)
            at kotlinx.coroutines.JobSupport.tryFinalizeSimpleState(JobSupport.kt:276)
            at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:807)
            at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:787)
            at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:111)
            at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
            at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
            at android.os.Handler.handleCallback(Handler.java:883)
            at android.os.Handler.dispatchMessage(Handler.java:100)
            at android.os.Looper.loop(Looper.java:214)
            at android.app.ActivityThread.main(ActivityThread.java:7356)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
    amar_1995
    6 replies
    Copy to Clipboard
  • m

    Mate

    2 years ago
    kapt still can't be used together with compose? I tried 0.1.0-dev04 still gets
    e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState$Builder.isIrBackend(Z)Lorg/jetbrains/kotlin/codegen/state/GenerationState$Builder;
    https://issuetracker.google.com/u/1/issues/143232368 https://youtrack.jetbrains.com/issue/KT-34583
    m
    jim
    15 replies
    Copy to Clipboard