Thread
#multiplatform
    s

    Sean Proctor

    2 months ago
    For a KMP project that just targets android and jvm, is it possible to get Android Studio/IntelliJ to not mark Java-specific stuff as an error?
    xxfast

    xxfast

    2 months ago
    you shouldn't reference java specific stuff in
    commonMain
    anyways.
    commonMain
    is only for pure-kotlin (jvm-free)
    if you really really want to, you can use typealiases for it
    //commonMain
    expect class Random
    
    //jvmMain
    actual typealias Random = java.util.Random
    
    //androidMain
    actual typealias Random = java.util.Random
    keep in mind, that jvm and android are two different targets and the
    Random
    above may not be the same
    s

    Sean Proctor

    2 months ago
    Thanks, trying that.
    Specifically I'm trying to use File. So if I want to use any methods or Kotlin extensions, I guess I need to make expect/actual declarations for those too.
    e

    ephemient

    2 months ago
    as a workaround to lighten the workload a bit: if you create a separate KMP module with only a JVM target, you can declare the
    actual
    only once. then using that a
    commonMain
    dependency in your JVM+Android project, you'll have the same actual in both
    s

    Sean Proctor

    2 months ago
    Thanks guys. Not the answer I was hoping for, but I appreciate the help. Did someone make a KMP file library to make my life easier?
    e

    ephemient

    2 months ago
    okio filesystem supports KMP https://square.github.io/okio/file_system/
    s

    Sean Proctor

    2 months ago
    Looks better than whatever I'd do. .. and with testing! Thanks!