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

[Crash] Koin Logger Measure and Kotlin EAP 1.4-M3 #847

Closed
ParaskP7 opened this issue Jul 9, 2020 · 26 comments
Closed

[Crash] Koin Logger Measure and Kotlin EAP 1.4-M3 #847

ParaskP7 opened this issue Jul 9, 2020 · 26 comments
Labels
Milestone

Comments

@ParaskP7
Copy link

ParaskP7 commented Jul 9, 2020

Describe the bug
This is just a heads up on Koin and Kotlin EAP 1.4-M3.

After upgrading to Kotlin EAP 1.4-M3 (from previous Kotlin EAP 1.4-M2) when launching the app a NoSuchMethodException exception is thrown due to the elapseNow() experimental method.

Full exception below:

    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/io.petros.movies-u-dzv9wkMPKfx19uLVQWyg==/base.apk)
        at org.koin.core.time.MeasureKt.measureDuration(Measure.kt:36)
        at org.koin.core.KoinApplication.modules(KoinApplication.kt:60)
        at io.petros.movies.app.App$initKoin$1.invoke(App.kt:45)
        at io.petros.movies.app.App$initKoin$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 io.petros.movies.app.App.initKoin(App.kt:42)
        at io.petros.movies.app.App.onCreate(App.kt:34)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1189)
        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)

This is due to the fact that my app is using androidLogger(), which default to a Koin log level of Level.INFO and as such when modules are build the duration is measured, which crashes the app. To overcome this I disabled logging for now, but it will be good if that get fixed so that I can enable it again.

To Reproduce
Steps to reproduce the behavior:

  1. Use Kotlin EAP 1.4-M3 as a dependency in your app (or project)
  2. During Koin init start with default logging enabled (Level.INFO)
  3. Launch your app (or project)
  4. See error

Expected behavior
I except the app to not crash.

Koin project used and used version (please complete the following information):
org.jetbrains.kotlin:kotlin-stdlib:1.4-M3
org.koin:koin-core:2.1.6
org.koin:koin-android:2.1.6
org.koin:koin-androidx-viewmodel:2.1.6

Additional moduleDefinition
No additional moduleDefinition.

ParaskP7 added a commit to ParaskP7/sample-code-movies that referenced this issue Jul 9, 2020
As part of this update the below changes occurred:
1) 'initKoin' and 'androidLogger()' was updated to 'Level.ERROR' from
the default 'Level.INFO'. This is due to the fact that otherwise the app
crashes, see: InsertKoinIO/koin#847
2) Coverage numbers were update for both the 'network' and 'core'
modules. Mainly on 'instruction' and 'line' levels.
@stevenzeck
Copy link

I'm still using Kotlin 1.3.72 and received this error.

@smelfungus
Copy link

smelfungus commented Jul 28, 2020

I'm facing the same issue with 1.4.0-rc too.
Temporary workaround:
Migrate from androidLogger() to androidLogger(Level.ERROR)

@upachecog
Copy link

I'm facing the same issue with 1.4.0-rc too.
Temporary workaround:
Migrate from androidLogger() to androidLogger(Level.ERROR)

I am facing the same issue with koinVersion = '2.1.6'.

This workaround is working btw.

@hoc081098
Copy link

Kotlin 1.4 becomes stable, waiting new release 🌸

@mannodermaus
Copy link

FWIW the encapsulated functionality of modules() is public, so you'd also be able to work around this by inlining the work of that method in your own setup. This way, there is no need to lose all info-level logging going forward.

// 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()
}

@arnaudgiuliani
Copy link
Member

I have to check & help migration to Kotlin 1.4 for Koin 2.2.0. From what I see here, is the time measurement stuff that are still having problems :/

@arnaudgiuliani arnaudgiuliani added this to the 2.2.0 milestone Aug 17, 2020
@roschlau
Copy link

roschlau commented Aug 17, 2020

Same problem here, updating to stable Kotlin 1.4 bricks loading the modules because the still experimental time API seems to have changed something under the hood, I'm using a modified copy of modules now that doesn't use the time API to fix this.

@arnaudgiuliani Would have been nice to know upfront that Koin is using unstable experimental API under the hood, and in such a core code path even - silently opting in to the ExperimentalTime annotation seems like a questionable choice here

@arnaudgiuliani
Copy link
Member

yep could clearly remove this experimental API that keep moving from release to release

👍

@stevyhacker
Copy link

I got this crash after updating to stable Kotlin 1.4.0 while everything worked fine before on 1.3.72 Kotlin and 2.1.6 Koin.

@BuryYa
Copy link

BuryYa commented Aug 21, 2020

Kotlin 1.3.72 + Koin 2.1.5 - OK
Kotlin 1.4 + Koin 2.1.5 - Error

@Pitel
Copy link
Contributor

Pitel commented Aug 21, 2020

Would be nice to release 2.1.7 with just this fixed. This is the only way that's stopping my team from updating to Kotlin 1.4. (Sure, there are workarounds, but...)

@wax911
Copy link

wax911 commented Aug 21, 2020

I'm facing the same issue with 1.4.0-rc too.
Temporary workaround:
Migrate from androidLogger() to androidLogger(Level.ERROR)

Setting the log level to Level.None also works since the exception happens when Koin needs to log something, completely avoiding java.lang.NoSuchMethodError crash

wax911 added a commit to AniTrend/retrofit-graphql that referenced this issue Aug 21, 2020
@irgaly
Copy link

irgaly commented Aug 25, 2020

Kotlin 1.4 + 2.2.0-alpha-1 works well.

shkschneider pushed a commit to shkschneider/android_Skeleton that referenced this issue Aug 25, 2020
Not finished and crashes because of an ongoing Koin bug
InsertKoinIO/koin#847
shkschneider pushed a commit to shkschneider/android_Skeleton that referenced this issue Aug 26, 2020
Crashes with Koin because of an ongoing bug:
InsertKoinIO/koin#847
adhirajsinghchauhan added a commit to oxygen-updater/oxygen-updater that referenced this issue Aug 28, 2020
- Kotlin 1.4.0 (from 1.3.72): https://blog.jetbrains.com/kotlin/2020/08/kotlin-1-4-released-with-a-focus-on-quality-and-performance/
  `stdlib` dependency doesn't need to be explicitly added anymore: https://kotlinlang.org/docs/reference/whatsnew14.html#dependency-on-the-standard-library-added-by-default
  Had to switch Koin's logger to ERROR for `androidLogger`. See InsertKoinIO/koin#847.
- Play Core 1.8.0: mostly for https://developer.android.com/guide/playcore/in-app-review, which may be implemented in a future commit
@DDihanov
Copy link

DDihanov commented Sep 1, 2020

Kotlin 1.4 + 2.2.0-alpha-1 works well.

Can confirm - this works for me.

Pulimet added a commit to Pulimet/SamplesApp that referenced this issue Sep 21, 2020
… logging crash. Could be changed to stable 2.1.7 when it released. Reference: InsertKoinIO/koin#847
adhirajsinghchauhan added a commit to oxygen-updater/oxygen-updater that referenced this issue Oct 10, 2020
- Kotlin 1.4.10 (from 1.4.0): https://blog.jetbrains.com/kotlin/2020/08/kotlin-1-4-released-with-a-focus-on-quality-and-performance/
  Important bugfixes and perf improvements
- Koin 2.2.0-rc-2 (from 2.1.6)
  In 2.1.6, had to switch Koin's logger to ERROR for `androidLogger`. See InsertKoinIO/koin#847 (happens only on Kotlin 1.4+).
- Google Play Billing 3.0.1 (from 3.0.0)
  https://developer.android.com/google/play/billing/release-notes#3-0-1
- Switched to Firebase BoM and KTX-variants
  Mostly to simplify Firebase versioning
@lucasls
Copy link

lucasls commented Oct 22, 2020

Release Candidate version 2.2.0-rc-3 has this issue fixed

@erikhuizinga
Copy link

This issue has been around since July and has been fixed since August, but hasn't been released yet in November. I know there have been alpha, beta and rc versions that include this fix, but there is no stable release yet. What is standing in the way of this release?

@raxander67
Copy link

Kotlin 1.4.10 + Koin 2.2.1 - this works for me.

@kldMohammed
Copy link

I have the propblem when i adding kotlin datetime lib

@AzraelWarrior
Copy link

same issue
kotlin 1.5.0 + koin 3.0.1

@collinsmao
Copy link

same issue
kotlin 1.5.0 + koin 3.0.1

androidLogger(Level.INFO) crashed

@mansoorexpert
Copy link

Kotlin 1.4.32 + Koin 2.2.2 - worked for me.

@prefectAtEarth
Copy link

same issue
kotlin 1.5.20 + koin 3.0.1
@arnaudgiuliani could you please reopen this issue as it semms not to be fixed / to reappear in koin 3.0.1

@JajaComp
Copy link

JajaComp commented Jul 1, 2021

same issue
kotlin 1.5.20 + koin 3.0.1
@arnaudgiuliani could you please reopen this issue as it semms not to be fixed / to reappear in koin 3.0.1

Try koin n 3.1.1

@arnaudgiuliani
Copy link
Member

Yes Koin 3.1.x is upgrading Kotlin compat

@EarthDragon88
Copy link

EarthDragon88 commented Jan 25, 2022

please reopen:
I'm having the same issue
kotlin 1.6.10
koin 3.1.5

@yusufgltc
Copy link

Add where you configure your koin

slf4jLogger(level = Level.ERROR)

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

No branches or pull requests