I have the following base class:
abstract class BaseFragment<T : BaseViewModel> : Fragment(), JobHolder {
protected lateinit var viewModel: T
private set
protected fun provideViewModel(type: Class<T>) {
viewModel = ViewModelProviders.of(this).get(type)
}
}
and the following class:
class SubjectEditor : BaseFragment<SubjectEditorViewModel>() {
override fun onAttach(context: Context?) {
super.onAttach(context)
provideViewModel(SubjectEditorViewModel::class.java)
}
}
But ProGuard is complaining:
Warning: cz.x.ui.subjects.SubjectEditor: can't find referenced method 'void setViewModel(cz.x.ui.BaseViewModel)' in program class cz.x.ui.subjects.SubjectEditor
I tried some -keep
rules for ProGuard, but nothing worked. What's the correct solution?
I guess you want it not to be obfuscated, so in that case you should keep the methods in the abstract class:
-keep public class {path to your class}.BaseFragment{
private <methods>;
}
There's a really usefull ProguardGuide in this link After reading it you should be more confident on which rules you should use.
I hope it helps, otherwise let me know!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.