Hi! I trying to make android/iOS project, but have...
# multiplatform
a
Hi! I trying to make android/iOS project, but have some problems with dependencies for "actual" part of common code. (details inside thread, coming soon)
gradle.build
Copy code
apply plugin: 'kotlin-multiplatform'

kotlin {
    targets {
        final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos")  \
                               ? presets.iosArm64 : presets.iosX64

        fromPreset(iOSTarget, 'iOS') {
            compilations.main.outputKinds('FRAMEWORK')
        }

        fromPreset(presets.jvm, 'android')
    }
    sourceSets {
        commonMain.dependencies {
            api 'org.jetbrains.kotlin:kotlin-stdlib-common'
        }

        androidMain.dependencies {
            api 'org.jetbrains.kotlin:kotlin-stdlib'
        }
    }
}
dependencies {
    def google_services = "16.0.0"
    androidMainApi "com.google.android.gms:play-services-maps:$google_services"
    androidMainApi "com.google.android.gms:play-services-location:$google_services"
}
configurations {
    compileClasspath
}
But those dependencies not resolved under project files. Where I'm wrong?
i
You should move maps to Android app but not in multi platforms
a
But I suppose that
expect/actual
paradigm is for separation of common AND platform specific code?
@itnoles Okay. I have common class
Copy code
data class Accident(val....., val location: AccidentLocation, ...)
Also I have
expect
class
Copy code
expect class AccidentLocation {
    fun distanceTo(point: AccidentLocation): Double
}
Every platform have their own approach to work with
locations
and it is reasonable to use those classes and methods inside actual platform specific code, didn't it? Or I'm wrong?
n
Your gradle file is wrong. JVM is not Android, you need access to Android API’s so you need to genereate an AAR.
So you need an Android target, with a manifest and that sort of things. Look for samples from Jetbrains on github.
Also, you of course cannot use platform specific classes in a common declaration. You need to write your own wrappers for LatLong etc.