Hello how can we only import android.util.Log insi...
# kotlin-native
m
Hello how can we only import android.util.Log inside commonAndroid pleaz?
j
There is no commonAndroid, there is an android target which should be able to identify
import android.util.Log
correctly. If you want to create a common Logger you first need to setup the
expect
class/interface in common and then implement the
actual
setup in android and your other platform targets
m
sorry i mean my androidMain, when i try import android.util.Log i have a Unresolved reference
as dependencies i have : androidMain.dependencies { api 'org.jetbrains.kotlin:kotlin-stdlib' implementation 'org.jetbrains.kotlinxkotlinx coroutines android1.1.1' implementation 'org.jetbrains.kotlinxkotlinx serialization runtime0.9.0' implementation("io.ktorktor client android$ktor_version") }
j
If you have the android target setup and installed, the import should work, given that the directory path is correctly setup according to how you setup the targets and configured the android dsl
android {.....}
needs to be implemented
Copy code
kotlin {
    targets {
        fromPreset(presets.android, 'android')`
    }
}
also needs exist
You can find an example on how to wire it here: https://github.com/JetBrains/kotlin-mpp-example
m
I see thank you, is it a good way tho to implement a logger like that by adding actual Log from androidandroid.util.Log for android and actual log from platform.Foundation.NSLog?
i need to use log inside my commonMain
j
Yes, it is going to come in handy