frankiesardo/icepick

Doesn't work with Dagger2

NitroG42 opened this issue · 3 comments

I just added icepick on a project that uses Dagger2. (I use kotlin too but it shouldn't be a problem)
I have a fragment with a value I want to save, kinda like that :

class MyFragment : Fragment() {
    @State
    var myValue: Float = 0f
    @Inject
    val networkApi: NetworkApi   

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Icepick.restoreInstanceState(this, savedInstanceState)
    }
    override fun onSaveInstanceState(outState: Bundle?) {
        super.onSaveInstanceState(outState)
        Icepick.saveInstanceState(this, outState)
    }
}

And when I build, I got this error :
Error:Don't know how to put a my.package.NetworkApi inside a Bundle.
But NetworkApi doesn't have the @State (and it's in an abstract class too...)
Is there something I'm missing ? I think there is somekind of a problem with dagger2 annotation and icepick's one.

Can you reproduce it using Java? Try to narrow down the problem to a
minimal failing example
On 22 Apr 2016 1:38 p.m., "NitroG42" notifications@github.com wrote:

I just added icepick on a project that uses Dagger2. (I use kotlin too but
it shouldn't be a problem)
I have a fragment with a value I want to save, kinda like that :
class MyFragment : Fragment() {
@State https://github.com/State
var myValue: Float = 0f
@Inject https://github.com/Inject
val networkApi: NetworkApi

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Icepick.restoreInstanceState(this, savedInstanceState)
}
override fun onSaveInstanceState(outState: Bundle?) {
super.onSaveInstanceState(outState)
Icepick.saveInstanceState(this, outState)
}

}

And when I build, I got this error :
Error:Don't know how to put a my.package.NetworkApi inside a Bundle.
But NetworkApi doesn't have the @State https://github.com/State (and
it's in an abstract class too...)
Is there something I'm missing ? I think there is somekind of a problem
with dagger2 annotation and icepick's one.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#83

I tried with a fresh project in Java, it works, I converted it in Kotlin, it works too.
I need to narrow down the error on my project. I'll comment here if I find the exact cause.

I looked more into this, and actually the problem comes from Kotlin and clojure, they definitelly doesn't work well together.