Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After updating Koin 2.1.6 version I Got crash like. java.lang.NoSuchMethodError: No virtual method elapsedNow()D in class Lkotlin/time/TimeMark; or its super classes (declaration of 'kotlin.time.TimeMark' appears .... #871

Closed
mcnarek opened this issue Aug 17, 2020 · 17 comments

Comments

@mcnarek
Copy link

mcnarek commented Aug 17, 2020

java.lang.NoSuchMethodError: No virtual method elapsedNow()D in class Lkotlin/time/TimeMark; or its super classes (declaration of 'kotlin.time.TimeMark' appears in /data/app/my.app.id-IIFeKPZKJaPEihLziq4cTg==/base.apk!classes3.dex)
    at org.koin.core.time.MeasureKt.measureDuration(Measure.kt:36)
    at org.koin.core.KoinApplication.modules(KoinApplication.kt:60)
    at my.app.id.App$onCreate$1.invoke(App.kt:51)
    at my.app.id.App$onCreate$1.invoke(App.kt:23)
    at org.koin.core.context.ContextFunctionsKt.startKoin(ContextFunctions.kt:39)
    at org.koin.core.context.ContextFunctionsKt.startKoin$default(ContextFunctions.kt:35)
    at my.app.id.App.onCreate(App.kt:40)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
    at android.app.ActivityThread.access$1300(ActivityThread.java:219)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)`

in App.kt (Application) class in onCreate method

`startKoin {
            // use AndroidLogger as Koin Logger - default Level.INFO
            androidLogger()

            // use the Android context given there
            androidContext(this@App)

            // load properties from assets/koin.properties file
            androidFileProperties()

            // module list
            modules(listOf(module1, module2, module3))
        }`

UODATE: Similar issue appeared on 3.0.1 version

@mcnarek
Copy link
Author

mcnarek commented Aug 17, 2020

Sorry this was after 1.4 update of Kotlin standard lib

@mcnarek mcnarek closed this as completed Aug 17, 2020
@mcnarek mcnarek reopened this Aug 17, 2020
@JosephSanjaya
Copy link

are there any solution? i also get this crashes, after update kotlin to 1.4.0.

@GabrielBrasileiro
Copy link
Contributor

GabrielBrasileiro commented Aug 18, 2020

@JosephSanjaya we have the answer in this other Issue.

1 - You can migrate the logger from androidLogger() to androidLogger(Level.ERROR) by @dummyco

2 - You can use the val inside KoinApplication like this:

// Before:
startKoin {
    androidLogger()
    androidContext(this@MyApplication)

    modules(koinModules)
}

// After:
startKoin {
    androidLogger()
    androidContext(this@MyApplication)

    // TODO Await fix for Koin and replace the explicit invocations
    //  of loadModules() and createRootScope() with a single call to modules()
    //  (https://github.com/InsertKoinIO/koin/issues/847)
    koin.loadModules(koinModules)
    koin.createRootScope()
}

by @mannodermaus

@mcnarek
Copy link
Author

mcnarek commented Aug 19, 2020

@GabrielBrasileiro yes that's Fixed for me, thanks

@sipersso
Copy link

@JosephSanjaya we have the answer in this other Issue.

1 - You can migrate the logger from androidLogger() to androidLogger(Level.ERROR) by @dummyco

2 - You can use the val inside KoinApplication like this:

// Before:
startKoin {
    androidLogger()
    androidContext(this@MyApplication)

    modules(koinModules)
}

// After:
startKoin {
    androidLogger()
    androidContext(this@MyApplication)

    // TODO Await fix for Koin and replace the explicit invocations
    //  of loadModules() and createRootScope() with a single call to modules()
    //  (https://github.com/InsertKoinIO/koin/issues/847)
    koin.loadModules(koinModules)
    koin.createRootScope()
}

by @mannodermaus

I am using a library that has a Koin dependency and this crashes whenever trying to run code from their framework. Is there any way to work around this issue if Koin is used by a library? I don't have any direct dependencies to Koin in my application so I am not the one calling startKoin.

@loalexzzzz
Copy link

@JosephSanjaya we have the answer in this other Issue.

1 - You can migrate the logger from androidLogger() to androidLogger(Level.ERROR) by @dummyco

2 - You can use the val inside KoinApplication like this:

// Before:
startKoin {
    androidLogger()
    androidContext(this@MyApplication)

    modules(koinModules)
}

// After:
startKoin {
    androidLogger()
    androidContext(this@MyApplication)

    // TODO Await fix for Koin and replace the explicit invocations
    //  of loadModules() and createRootScope() with a single call to modules()
    //  (https://github.com/InsertKoinIO/koin/issues/847)
    koin.loadModules(koinModules)
    koin.createRootScope()
}

by @mannodermaus

thanks, work in ktro as well.

@lucasls
Copy link

lucasls commented Oct 22, 2020

You can update to Release Candidate version 2.2.0-rc-3, it was fixed here: https://github.com/InsertKoinIO/koin/blob/master/CHANGELOG.md#user-content-220-beta-1:~:text=fixed%20time%20API%20%2D%20Kotlin%201.4

@benedictcontawe
Copy link

This works Thanks!

@sipersso
Copy link

sipersso commented May 8, 2021

Looks like this issue has shown up again. I am not using Koin directly

@Icyrockton
Copy link

when using kotlinx-datetime this issue happened in Android platform

androidLogger(Level.ERROR)

solve this problem

@RdeWilde
Copy link
Contributor

RdeWilde commented May 19, 2021

Looks like this issue has shown up again. I am not using Koin directly

I am experiencing this issue too, using 3.0.1. The fix might have landed in 2.x but not in 3.x?
@mcnarek do you care to re-open this issue?

Replacing

        initKoin {
            androidLogger()

with

        initKoin {
            androidLogger(Level.ERROR) // Or any other level I guess

fixed it for me

@mcnarek
Copy link
Author

mcnarek commented May 19, 2021

Still need to re-open issue? or solved?

@mcnarek mcnarek reopened this May 19, 2021
@RdeWilde
Copy link
Contributor

I think the original problems isnt solved as we need the work-around. Thanks

jvtrigueros added a commit to guacamoledragon/throw-voice that referenced this issue May 22, 2021
Not sure if this issue is related to Koin or Kotlin, but this is the bug
report InsertKoinIO/koin#871
@dexpota
Copy link

dexpota commented Jun 10, 2021

In my case, this issue was caused by multiple JAR files in the classpath with different versions. This was the warning issued by the building procedure:

w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /*/.gradle/caches/transforms-2/files-2.1/4487fd127f7a08e89641cd654045a160/jetified-kotlin-stdlib-jdk8-1.4.30.jar (version 1.4)
    /*/.gradle/caches/transforms-2/files-2.1/e126886026a6667eeb50243be13308b3/jetified-kotlin-stdlib-jdk7-1.4.30.jar (version 1.4)
    /*/.gradle/caches/transforms-2/files-2.1/a1c4be33b69edf7445c8b8a868539716/jetified-kotlin-reflect-1.4.30.jar (version 1.4)
    /*/.gradle/caches/transforms-2/files-2.1/77ad8de65641e29d0ce63bef5c066de6/jetified-kotlin-stdlib-1.5.10.jar (version 1.5)
    /*/.gradle/caches/transforms-2/files-2.1/4fad198518f8113eba0ffc5a9066173f/jetified-kotlin-stdlib-common-1.5.10.jar (version 1.5)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

I verified that this was the issue by forcing the version resolution of org.jetbrains.kotlin:kotlin-stdlib to 1.4.30.

implementation("org.jetbrains.kotlin:kotlin-stdlib") {
    version {
        strictly("1.4.30")
    }
}

Maybe this piece of information could be useful.

@benyam7
Copy link

benyam7 commented Jul 12, 2021

Personally, I was using different versions of koin for KMM project I was working on. After changing the koin version to 3.1.1 for all modules (android and common) removed the error for me.

@stale
Copy link

stale bot commented Mar 23, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@mcnarek
Copy link
Author

mcnarek commented Mar 29, 2022

Closing this because of inactivity.

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

No branches or pull requests