https://kotlinlang.org logo
#android
Title
# android
j

jonnothebonno

04/04/2017, 11:59 AM
Hey guys is this an appropriate place to ask about potential issues with Kotlin on Android? 🤔 - I have a really bizzar issue that might be being caused by me but anyways… I’ve created a simple event dispatcher that’s lazy initialised like so
Copy code
companion object {
        val instance by lazy { EventDispatcher() }
    }
and whenever I add anything to it and try to dispatch an event, I receive the following error
java.lang.NoClassDefFoundError: jonnothebonno.me.app.notifications.events.EventDispatcher$dispatchEvent$1
The weird thing is, this only appears to happen on older mobiles. Works perfect on my pixel but crashes on my nexus 5. I’m using
Kotlin 1.1.1
and
gradle 2.3.0
l

louiscad

04/04/2017, 12:27 PM
Does this happens on debug builds only?
j

jonnothebonno

04/04/2017, 2:00 PM
Hey Louis. No it happens on both debug and release builds. 😰
l

louiscad

04/04/2017, 3:07 PM
@jonnothebonno Can you show me the code of
EventDispatcher
? Consider private message if it can't be public
j

jonnothebonno

04/04/2017, 3:08 PM
Yeah sure, one moment.
l

louiscad

04/04/2017, 3:18 PM
@jonnothebonno Haha, simple. Just add parenthesis around the lambda parameters
You're calling some java 8 code. Adding parenthesis means destructuration, and this is from kotlin's stdlib, not java 8
j

jonnothebonno

04/04/2017, 3:19 PM
omg really? thank you 🤣 stupid me
l

louiscad

04/04/2017, 3:19 PM
@jonnothebonno Let me know if it worked fine
j

jonnothebonno

04/04/2017, 3:20 PM
Will try it now!
it worked! thank you so much 😄
😉 1
6 Views