https://kotlinlang.org logo
Join SlackCommunities
Powered by
# moko
  • f

    FaN

    05/08/2024, 4:12 PM
    is it just me that putting images into moko-resources/images just doesnt work at all?
  • f

    FaN

    05/08/2024, 4:13 PM
    in the sharedRes.kt, it can't work the drawable stuff...
  • f

    FaN

    05/08/2024, 4:13 PM
    i have fonts and strings that work fine
  • f

    FaN

    05/08/2024, 4:14 PM
    e: file///Users/user/Development/APP/Source/shared/build/generated/kotlin/generateMRandroidMain/com/app/kmm sharingresources/SharedRes.kt247:66 Unresolved reference: drawable
  • f

    FaN

    05/09/2024, 6:18 PM
    Really though, still works in android, still get this : Uncaught Kotlin exception: kotlin.IllegalArgumentException: can't read UIImage of ImageResource(assetImageName=ss_background, bundle=NSBundle </var/containers/Bundle/Application/443A8F57-1EE9-4148-8D68-5B6BF19E263E/###.app/###:shared.bundle> (not yet loaded))
  • f

    FaN

    05/09/2024, 6:19 PM
    issues has this : https://github.com/icerockdev/moko-resources/issues/680 but it's not very clear
  • f

    FaN

    05/09/2024, 6:20 PM
    that error is in xcode if anyone has any ideas 😞
  • f

    FaN

    05/09/2024, 6:38 PM
    changed 0.24.0-beta-1 to 0.24.0-beta-2 -.- as you all were...
  • s

    Suresh Maidaragi

    05/14/2024, 12:22 PM
    Hi there, we are unable to render the
    .html file
    post updating moko resource library to 0.24.0-beta-3. and we are able to render other files except
    .html file
    a
    • 2
    • 5
  • l

    Lee Wilson

    05/17/2024, 9:52 AM
    Hello there, we seem to be getting crashes while using moko permissions in our Android app:
    Copy code
    Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
           at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1632)
           at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1672)
           at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:341)
           at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:306)
           at dev.icerock.moko.permissions.PermissionsControllerImpl.getOrCreateResolverFragment(PermissionsControllerImpl.kt:124)
           at dev.icerock.moko.permissions.PermissionsControllerImpl.getPermissionState(PermissionsControllerImpl.kt:90)
           at dev.icerock.moko.permissions.PermissionsControllerImpl.isPermissionGranted(PermissionsControllerImpl.kt:66)
    Has anyone encountered this one before? This is using lib version 0.16.0, Android 14.
  • g

    Giorgi

    05/21/2024, 4:25 PM
    Hi. I have added moko resources library to the project but for some reason it does not generate MR class
    g
    d
    • 3
    • 9
  • b

    Blaž Vantur

    06/04/2024, 2:16 PM
    Hey. 🙂 I’ve created an issue on Github for Phrase localization service for OTA in combination with moko-resources library here: https://github.com/phrase/ios-sdk/issues/72 I think this is something that needs to be address from Phrase side, but maybe someone else has an idea how to solve this from the moko library side?
    a
    • 2
    • 4
  • g

    George Karpenko

    06/05/2024, 11:22 AM
    Hi! Firstly i've setup my project with
    moko-resources:0.24.0-beta-4
    and kotlin
    1.9.23
    . I've copied moko-resources manually via task:
    Copy code
    ./gradlew shared:copyResourcesSharedReleaseXCFrameworkToApp \
          -Pmoko.resources.BUILT_PRODUCTS_DIR="$BUILT_PRODUCTS_DIR" \
          -Pmoko.resources.CONTENTS_FOLDER_PATH="$CONTENTS_FOLDER_PATH"
    And everything worked fine there. Now i'm upgrading to kotlin
    2.0.0
    and latest
    moko-resources:0.24.0-beta-5
    with already added
    configureCopyXCFrameworkResources("shared")
    instead of custom script. But after
    linkReleaseFrameworkIosArm64
    succeeded i do my custom
    copyXCFramework
    which is:
    Copy code
    fun Task.copyXCFramework(projectName: String) {
        val buildPathRelease =
            "build/bin/ios${if (isIosSimulator()) "Simulator" else ""}Arm64/releaseFramework/$projectName.framework"
        val iosXCBinaryPath = "../iosApp/Libraries/$projectName.xcframework"
    
        project.delete(iosXCBinaryPath)
        project.copy {
            from(buildPathRelease)
            into(iosXCBinaryPath)
        }
    }
    so on this stage i'm not able to copy moko files, because it fails on:
    Copy code
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring project ':shared'.
    > Could not create task ':shared:copyXCFramework'.
       > Cannot convert URL 'sts-client.shared:localization.bundle' to a file.
    Can you help me with this without repro?
    • 1
    • 2
  • k

    khalid64927

    06/29/2024, 12:20 PM
    has anyone used "multiplatform-all" plugin by moko-gradle-plugin for building Mobile, wasmJs and jvm targets
    a
    • 2
    • 3
  • j

    Jazmine Barroga

    07/18/2024, 1:58 PM
    hello! how do you specify to moko that it should only localize specific strings.xml files? we have the strings.xml files in the commonMain.moko-resources directory but it seems that moko also tries to lint the xml files from other directories which are not necessarily for localization 🙂
    a
    • 2
    • 4
  • s

    Shakhzod Ilkhomov

    07/25/2024, 5:59 AM
    Hello everyone. Does somebody know how to use moko-geo in KMP project (Jetpack Compose/SwiftUI)?
    Copy code
    // bind tracker to lifecycle
    viewModel.locationTracker.bind(lifecycle, this, supportFragmentManager)
    I don't know how to bind this locationTracker as I don't have supportFragmentManager in my project..(
  • v

    Vladimir Malykhin

    07/26/2024, 7:29 AM
    Hello everyone. Does somebody know how to use moko-media in KMP project with new iOS correctly? I have a problem with iOS 17.4 ver, when i use recomended request Camera like
    Copy code
    mediaPickerController.pickImage(MediaSource.CAMERA)
    when I make photo and come back to screen, I can not receive Bitmap and have a problem with screen composition ^ for example - main top app bar relocate to up to place system tip app bar and not answered of click back action I use next version moko
    Copy code
    moko.permissions.version = 0.17.0
    moko.media.version = 0.11.0
    a
    • 2
    • 3
  • a

    Antonis Radz

    10/16/2024, 9:42 AM
    I would suggest to use compose resources instead
    a
    • 2
    • 1
  • m

    Muaz KADAN

    10/22/2024, 8:23 AM
    Hi everyone, just wondering if I can create an xcframework of my shared code that has moko-resources and give to iOS team to use it in their project directly ?
    a
    • 2
    • 4
  • m

    Muaz KADAN

    10/24/2024, 2:13 PM
    The documentation here Github says:
    Moko-resources has out of box implementation function for read text files from common code - readText()
    But when I try to access
    readText()
    I can't find it am I missing something ?
    a
    • 2
    • 5
  • p

    Patrick Cavanagh

    10/28/2024, 4:04 PM
    Hi, was there any investigation done into this issue with Moko kSwift causing an issue for builds which have dependencies on cinterop libraries? Just trying to upgrade to Kotlin 2 and Ktor 3 and have run into this issue resulting in it not being possible to build my app in Xcode. Any workarounds?
  • m

    Muaz KADAN

    11/08/2024, 9:33 AM
    Hello there, is it possible to share webp images between android and iOS I tried with PNG but the size went up too much Thank you
  • h

    Harshad Pawar

    11/08/2024, 1:50 PM
    Has this issue got fixed https://github.com/icerockdev/moko-permissions/issues/132
  • h

    Harshad Pawar

    11/14/2024, 6:03 AM
    👋 Hi There hope you all are doing good ! I am facing issue with ask media access permission after granted on android its still showing permission is not granted on android 13 and 14 but same app I run on 9,8 there its working fine. I have check there is google library for permission state handling
    Copy code
    com.google.accompanist:accompanist-permissions
    is Moko is also using this library under the hood for remember permission state and permission result
    • 1
    • 1
  • m

    Matija Sokol

    12/04/2024, 9:43 AM
    With Kotlin 2.1.0 new Support for non-packed klibs feature is introduced. Since I'm using lib which hasn't migrate to latest Kotlin version, I need to revert this behavior to old one. From docs, it seems that I only need do this:
    Copy code
    import org.jetbrains.kotlin.gradle.plugin.attributes.KlibPackaging
    
    val resolvableConfiguration = configurations.resolvable("resolvable") {
        attributes.attribute(KlibPackaging.ATTRIBUTE, project.objects.named(KlibPackaging.PACKED))
    }
    But, if I run this my issue is still here. Exactly, problem is this. For reference, I'm working on KMP project. So, my questions are: • Is this code snippet only change I need to do or I need to apply
    resolvableConfiguration
    somewhere? • In which gradle file I need to do it (
    project
    or
    module
    level)?
    a
    • 2
    • 4
  • k

    Khush

    12/12/2024, 6:12 AM
    Hello, Is there any solution for the above error?
    Copy code
    FATAL EXCEPTION: main
                                                                                                        Process: com.jetbrains.kmpapp, PID: 24156
                                                                                                        java.lang.ClassCastException: com.jetbrains.kmpapp.MainActivity cannot be cast to androidx.fragment.app.FragmentActivity
                                                                                                        	at dev.icerock.moko.media.compose.BindMediaPickerEffect_androidKt$BindMediaPickerEffect$1.invokeSuspend(BindMediaPickerEffect.android.kt:24)
                                                                                                        	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
                                                                                                        	at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
                                                                                                        	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
                                                                                                        	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
                                                                                                        	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                        	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                        	at android.os.Looper.loop(Looper.java:294)
                                                                                                        	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                        	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                        	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
                                                                                                        	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@1538ab5, androidx.compose.runtime.BroadcastFrameClock@1d3654a, StandaloneCoroutine{Cancelling}@11adcbb, AndroidUiDispatcher@b5325d8]
    a
    • 2
    • 2
  • k

    kevin.cianfarini

    01/07/2025, 4:41 PM
    FYI — if you use Kotlin/Native and moko, you will be unable to upgrade to Kotlin 2.1.0 and have tests pass and will be unable to upgrade any dependencies that are built with Kotlin 2.1.0. It’s a forwards incompatible change for Kotlin/Native, meaning that libraries built with
    2.1.0
    cannot be consumed from
    2.0.X
    . See more here: https://github.com/icerockdev/moko-resources/issues/796#issuecomment-2575750611
    m
    a
    • 3
    • 12
  • m

    Muaz KADAN

    01/23/2025, 1:13 PM
    Hi, is there a way to get a StringResource from a string id in common code ? Something similar to this which gives and int id
    Copy code
    context.resources.getIdentifier(
        "hellow_message_$1",
        "string",
        context.packageName
    )
    d
    • 2
    • 2
  • d

    David Nedrow

    03/11/2025, 4:47 PM
    Gah, I can't get moko-resources integrated with gradle files. I'm having trouble converting the Groovy gradle.build examples (in the README) to the Kotlin Gradle DSL. Has anyone done this with the Kotlin DSL? If you have, can you share your setups for (root)
    gradle.build.kts
    , (project)
    gradle.build.kts
    , and
    libs.versions.toml
    ?
    • 1
    • 1
  • a

    Abhijeet Kumar

    03/21/2025, 5:35 AM
    Hello there, Wanted to know how much impact on size does moko-resource has on overall release variant of framework file for ios? We've a Kotlin only module in our android project which is also consumed by iOS project but even with bare metal libraries like SKIE, KTor and SqlDelight the release variant for exported .framework file is ~70MB
    a
    s
    • 3
    • 3