j

    Joffrey

    2 years ago
    Hi guys, if I compile with jvm target 8 or use java 8 dependencies for my JVM artifact in a multiplatform project, is it usable anyway from Android? Do I need to add an android-specific target?
    m

    magnumrocha

    2 years ago
    this is more a question for android channel, because it is about the support of java 8 features by the android, I recommend you read https://developer.android.com/studio/write/java8-support
    just to explain, in your case, the kmp module will produce a lib (java 8 support), so you question is: my android app will support this (java 8 compatible) lib?
    j

    Joffrey

    2 years ago
    Sorry if this question does not belong here. The slack channels have quite a bit of overlap and I find it difficult to find the right place (as opposed to tags on stackoverflow). I had already checked the page you linked, but it seemed to me that this was about Java 8 features supported in the Android project itself, through desugaring done by the build tool. Apparently, it also applies transformations on the dependencies, so I was wrong and it might help me in the end. However, I have no way of knowing whether my own dependencies make use of some Java 8 specific APIs that are not in the whitelist of this page 😞 Is there a way to check in my own gradle build that I’m compliant with the android toolchain? Is that a question for the gradle channel?
    m

    magnumrocha

    2 years ago
    no problem about your question, my intention is just to lead you to the right place for the next question 🙂, so, thinking in your use case, if some API of your library is not compliant with the Android Java 8 support, the compiler of Android toolchain will alert, and possibly will fail too.
    j

    Joffrey

    2 years ago
    That’s the thing, I am not using any android-specific toolchain at the moment in my MPP lib, just plain
    jvm
    and
    js
    targets. So I guess for now, it will only fail in the user’s android project (if it fails at all). I would like to find a way to configure my own MPP lib’s build so that it fails if I’m using android-incompatible dependencies or APIs. Do I need to add an android target and an android-lib plugin for this purpose?
    m

    magnumrocha

    2 years ago
    so, you can configure an android target on it, and make this target depends of your jvm target
    don't need to create the android source folder, just configure the target in kmp plugin and make the dependency...
    so, the compilation of your kmp lib will fails if it's not compliant of android
    j

    Joffrey

    2 years ago
    I see, thanks a lot for taking the time to answer. Do you know if there’s any existing example out there using this approach?
    m

    magnumrocha

    2 years ago
    I don't know, but let test it, who knows your project is the first one 😁
    j

    Joffrey

    2 years ago
    I’ll share my project if I manage to make this work
    I have seen this example, but they’re using a plain
    jvm
    target preset for the shared module’s android target