AAkira / Napier

Logging library for Kotlin Multiplatform
Apache License 2.0
820 stars 36 forks source link

Unresolved reference: Napier #28

Closed pecanw closed 4 years ago

pecanw commented 5 years ago

I've got an issue when trying to use the Napier logging library in the kotlin mpp project. The symptoms are exactly the same as described in the Issue 26 which has been closed.

To test the issue out of my project I have downloaded the official Kotlin mpp example and just upgraded the versions of gradle and kotlin and added the Napier library. You can find the project here: mpp-example.zip

I'm getting the error e: ...\mpp-example\greeting\src\commonMain\kotlin\common.kt: (3, 33): Unresolved reference: Napier

AAkira commented 4 years ago

You should implement the napier platform plugin, Android or iOS or JVM or JS.

This problem is not faulted by this library. Your gradle file is wrong.

kotlin {
    targets {
        fromPreset(presets.android, 'androidLib')

        def buildForDevice = project.findProperty("device")?.toBoolean() ?: false
        def iosPreset = (buildForDevice) ? presets.iosArm64 : presets.iosX64
        fromPreset(iosPreset, 'ios') {
            binaries {
                framework {
                    // Disable bitcode embedding for the simulator build.
                    if (!buildForDevice) {
                        embedBitcode("disable")
                    }
                }
            }
        }
    }

    sourceSets {
        commonMain {
            dependencies {
                implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
                implementation 'com.github.aakira:napier:1.0.0'
            }
        }
        commonTest {
            dependencies {
                implementation 'org.jetbrains.kotlin:kotlin-test-common'
                implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
            }
        }
        andriodTest {
            dependencies {
                implementation 'com.github.aakira:napier-android:1.0.0'
            }
        }
    }
}
        andriodLibMain {
            dependencies {
                implementation 'com.github.aakira:napier-android:1.0.0'
            }
        }