question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support of runtime Id creation

See original GitHub issue

I updated my project based on the recent commit of moko-widgets-template, so using 0.1.0-dev-18 now. And my code previously working with -dev12 throws an exception on Android run now.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.example.app.debug, PID: 18128
    dev.icerock.moko.widgets.utils.AndroidIdConflictException: id 0x7F081AB9 already used by org.example.mpp.MainScreen$createInput$1$2, it conflict with org.example.mpp.MainScreen$createInput$1$2
        at dev.icerock.moko.widgets.utils.IdExtKt.getAndroidId(IdExt.kt:45)
...

I stripped down the test case to minimum for reproducing the error:

  • use the current moko-widgets-template
  • replace MainScreen.kt with:
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package org.example.mpp

import dev.icerock.moko.fields.FormField
import dev.icerock.moko.fields.liveBlock
import dev.icerock.moko.resources.desc.StringDesc
import dev.icerock.moko.resources.desc.desc
import dev.icerock.moko.widgets.*
import dev.icerock.moko.widgets.core.Theme
import dev.icerock.moko.widgets.core.Widget
import dev.icerock.moko.widgets.screen.Args
import dev.icerock.moko.widgets.screen.WidgetScreen
import dev.icerock.moko.widgets.style.view.SizeSpec
import dev.icerock.moko.widgets.style.view.WidgetSize
import org.example.library.MR

class MainScreen(
    private val theme: Theme
) : WidgetScreen<Args.Empty>() {

    private fun createInput() : Widget<*>{
        return with(theme) {
            input(
                size = WidgetSize.WrapContent,
                label = const(MR.strings.hello_world.desc() as StringDesc),
                field = FormField(initialValue = "", validation = liveBlock { null }),
                id = object : InputWidget.Id {}
            )
        }
    }

    override fun createContentWidget() = with(theme) {
        constraint(size = WidgetSize.AsParent) {
            val scroll = +scroll(
                size = WidgetSize.Const(SizeSpec.MatchConstraint, SizeSpec.MatchConstraint),
                id = object : ScrollWidget.Id {},
                child = linear(
                    size = WidgetSize.Const(SizeSpec.AsParent, SizeSpec.WrapContent)
                ) {
                    +createInput()
                    +createInput()
                    +createInput()
                })

            constraints {
                scroll.topToTop(root.safeArea)
                scroll.leftRightToLeftRight(root.safeArea)
                scroll.bottomToBottom(root.safeArea)
            }
        }
    }
}

  • run in Android emulator

The input fields are generated dynamically, the id of the returned input field is a new object, but it seems that the moko-widgets lib thinks it’s the same. Or is the code just wrong and it’s not the right way to do it?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Alex009commented, Mar 24, 2020

i think we can add specific implementation of ID with string id, not class name…i mark issue as enhacement

0reactions
Alex009commented, Mar 31, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

<supportedRuntime> element - NET Framework
Specifies which common language runtime version and, optionally, .NET Framework version the application supports. <configuration>
Read more >
Runtime Support | Cloud Functions Documentation
Here is the list of currently supported Cloud Functions runtimes, as well as runtimes that have been deprecated and/or decommissioned. Note: You use...
Read more >
chrome.runtime - Chrome Developers
The Runtime API provides methods to support a number of areas of functionality that your extensions can use: Message passing: Your extension can...
Read more >
Custom AWS Lambda runtimes
A runtime is responsible for running the function's setup code, reading the handler name from an environment variable, and reading invocation events from...
Read more >
Add Servers to Runtime Manager - MuleSoft Documentation
If you must download the agent, you have an Enterprise support account. ... server appears on the Servers tab of Runtime Manager with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found