Hi guys, i’m having a weird build issue for on my ...
# multiplatform
l
Hi guys, i’m having a weird build issue for on my sharedModule. i’m trying to port google ML Kit api into KMP project. The Android app runs fine but the iOS build crashes whith the following error. The specific library i’m trying to import is :
implementation("com.google.mlkit:vision-common:17.3.0")
This is my
shared
gradle
Copy code
sourceSets {
    val commonMain by getting {
        dependencies {
            // PointF3D:
            implementation("com.google.mlkit:vision-common:17.3.0")
        }
    }
}
This is the build error Log
Copy code
> Task :shared:compileKotlinIosX64 FAILED
data/pose/PoseRepo.kt:11:12 Unresolved reference: google
data/pose/classification/MathUtil.kt:11:12 Unresolved reference: PointF3D
btw
klint
highlights the imported
com.google.mlkit.vision.common.PointF3D
library, but the Android project compiles and runs
l
The gradle is just for android. You'll need to find a cocoapod for iOS and create an expect/actual.
l
@Landry Norris i’m confused with your answer. what i’m trying to do is share a code between Android and iOS, and the code is not platform specific.
l
When you gradle sync, do you get errors saying it can't find vision-common for ios targets? I don't think MLKit supports KMM directly yet. You'll have to use expect/actual.
l
I get that kind of error if I include
implementation("com.google.mlkit:pose-detection-common:18.0.0-beta3")
Copy code
:shared:iosArm64Main: Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0.
Required by:
    project :shared > com.google.mlkit:pose-detection-common:18.0.0-beta3 > com.google.mlkit:acceleration:16.0.0-beta1 > androidx.work:work-multiprocess:2.7.0
    project :shared > com.google.mlkit:pose-detection-common:18.0.0-beta3 > com.google.mlkit:acceleration:16.0.0-beta1 > androidx.work:work-multiprocess:2.7.0 > androidx.work:work-runtime-ktx:2.7.0

Possible solution:
 - Declare repository providing the artifact, see the documentation at <https://docs.gradle.org/current/userguide/declaring_repositories.html>
but your answer about using expect/actual makes sense. Thank you.
l
Yeah. You're trying to import the android binary in commonMain. Move it to androidMain, add the pod to iosMain, and create an expect/actual.