Using Icepick without Annotation Processing?
mazurio opened this issue ยท 4 comments
Hi,
Is it possible to use Icepick without "@State" annotations? Can I manually add the objects I want to save? I would like to use Icepick with Kotlin but I cannot get it to work.
Thanks
I'd love to use kotlin too, but when you have Icepick
a simple class as
abstract class BaseFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return super.onCreateView(inflater, container, savedInstanceState)
}
}
fails to compile because of icepick processor.
13:46:45.179 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.IllegalArgumentException: (android.view.LayoutInflater,android.view.ViewGroup,android.os.Bundle)android.view.View
13:46:45.179 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.model.JavacTypes.validateTypeNotIn(JavacTypes.java:291)
13:46:45.179 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.model.JavacTypes.isAssignable(JavacTypes.java:102)
13:46:45.179 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
13:46:45.179 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
13:46:45.179 [ERROR] [org.gradle.BuildExceptionReporter] at icepick.processor$assignable_QMARK_.invoke(processor.clj:38)
13:46:45.179 [ERROR] [org.gradle.BuildExceptionReporter] at icepick.processor$parcelable_QMARK_.invoke(processor.clj:220)
13:46:45.179 [ERROR] [org.gradle.BuildExceptionReporter] at icepick.processor$bundle_method.invoke(processor.clj:239)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at icepick.processor$analyze_field.invoke(processor.clj:259)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.core$map$fn__4553.invoke(core.clj:2624)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.lang.LazySeq.sval(LazySeq.java:40)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.lang.LazySeq.seq(LazySeq.java:49)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.lang.RT.seq(RT.java:507)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.core$seq__4128.invoke(core.clj:137)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.core.protocols$seq_reduce.invoke(protocols.clj:30)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.core.protocols$fn__6506.invoke(protocols.clj:101)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.core.protocols$fn__6452$G__6447__6465.invoke(protocols.clj:13)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.core$reduce.invoke(core.clj:6519)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.core$group_by.invoke(core.clj:6861)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at icepick.processor$process.invoke(processor.clj:275)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at clojure.lang.Var.invoke(Var.java:388)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at icepick.processor.IcepickProcessor.process(IcepickProcessor.java:42)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.annotation.AnnotationProcessorWrapper.process(AnnotationProcessorWrapper.kt:115)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
13:46:45.180 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
13:46:45.181 [ERROR] [org.gradle.BuildExceptionReporter] at com.sun.tools.javac.main.Main.compile(Main.java:523)
13:46:45.181 [ERROR] [org.gradle.BuildExceptionReporter] ... 91 more
not really sure tough if it's the kotlin processor or icepick.
If you're not a fan of exposing your variables and using @JvmField, I've started a simple lib that should work as Icepick: https://github.com/tinsukE/icekick
Contributions are welcome!
@tinsukE your lib works great! Thanks man!
And here's another alternative. Same API like Icepick, but works well with properties: https://github.com/evernote/android-state