Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

mpp-iOS-Android: Unresolved reference: android #97

Open
tttzof351 opened this issue Nov 15, 2018 · 2 comments
Open

mpp-iOS-Android: Unresolved reference: android #97

tttzof351 opened this issue Nov 15, 2018 · 2 comments

Comments

@tttzof351
Copy link

When I just write as
actual fun platformName(): String { return "Android " + android.os.Build.VERSION.BASE_OS }
in SharedCode/src/androidMain/kotlin/actual.kt I get: Unresolved reference: android
so it's mean that android platform module don't support android sdk :(

@ausatiy ausatiy self-assigned this Nov 16, 2018
@paderick
Copy link

Same problem here. Android packages are not available in the android specific part. But in the ios specific part I can use e.g. the Foundation import.

@Maragues
Copy link

Maragues commented Dec 18, 2019

Could you please update this example? You are making a big investment into KMP, but the introductory example is almost 1 year old and it doesn't show how to reference android code.

For those who end up here looking for a solution, this tutorial helped me

Here are the relevant parts of my build.gradle.kts

plugins {
    id("com.android.library")
    kotlin("multiplatform")
}

android {
    compileSdkVersion(Versions.Android.compileSdk)

    defaultConfig {
        minSdkVersion(Versions.Android.minSdk)
        targetSdkVersion(Versions.Android.targetSdk)
    }

    sourceSets {
        getByName("main") {
            manifest.srcFile("src/androidMain/AndroidManifest.xml")
            java.srcDirs("src/androidMain/kotlin")
        }
    }
}

group = "com.kolibree"
version = "1.0-SNAPSHOT"

kotlin {
    android() 

   [...]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants