but then also, a bit of breaking (Scope API mostly...
# koin
a
but then also, a bit of breaking (Scope API mostly)
o
Hi, Arnaud Any clue on this issue? https://github.com/InsertKoinIO/koin/issues/797
We are planning to downgrade to
2.0.1
, since the first comment say that it was okay on this version we migrate from
1.0.2
directly to
2.1.6
, so we are quite lost about it 😬
a
seen that, could you provide a sample/project code to help investigate?
o
Sure, I can The thing is that we can’t reproduce it too 😞
a
is it linked to Obfuscation?
we need to reproduce it somewhere 😕
o
Hmmm hard to say, will search more insights inside the logs
if we couldn’t reproduce it would be hard indeed 😞
a
clearly 😕
do you see what component/injection is causing this?
and then can come over all your declarations?
o
Just found something weird on our logs
Copy code
ip #1
       at sun.misc.Unsafe.park(Unsafe.java)
       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:190)
       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2067)
       at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
       at bo.app.r.b(r.java:140)
       at bo.app.n$a.run(n.java:131)
       at java.lang.Thread.run(Thread.java:919)
Honestly, I think we didn’t tried to reproduce it in a signed + obfuscation version I’ll take a look
the issue happens when we try to inject Room
Copy code
class OneViewModel : ViewModel(), KoinComponent {

    private val database: AppDatabase? by inject<AppDatabase>()
}
Copy code
single {
        Room.databaseBuilder(androidContext(), AppDatabase::class.java, appDatabaseName)
            .fallbackToDestructiveMigration()
            .build()

    }
this is basically the setup
a
as you said, this is just a basic setup
why your database is
AppDatabase?
should just be
AppDatabase
and why do you make a
KoinComponent
here?
it’s a ViewModel, you can inject by constructor
KoinComponent
is there for API that has no extension ready for Koin injection
and most of you declaration must be done in constructor injection style in your module
try to limit yourself with inject extensions in Activity/Fragment
o
yep, I know it… it’s an old code made by someone that doesn’t know how to work with DI I was trying to avoid refectory this VIewModel but I ’ll take some time to do it
about the database nullable, I don’t know about it neither 😞
a
2 intersting to check here, you need to unplug components around the part that is failing and try one by one
can be not directly linked to Koin 😕
o
yes, I was thinking about it… we are injecting Room in others places and it’s fine even if the problem started after we upgrade it to
2.1.6
, I believe it’s related to how that screen is built I’ll try to reproduce it and I’ll come back to you if I got something Thanks for your support, mate 🙂
yep, it shouldn’t break much that if you were previously using it with success
but, let me know
👍 1