lateinit property Presenter has not been initialized
See original GitHub issueroutesPresenter.getRoutes(“18089”) thrown exception:
kotlin.UninitializedPropertyAccessException: lateinit property routesPresenter has not been initialized
class MainFragment: MvpAppCompatFragment(), RoutesView {
@InjectPresenter
lateinit var routesPresenter: RoutesPresenter
var adapter: RoutesAdapter = RoutesAdapter()
companion object{
fun newInstance(): MainFragment {
return MainFragment()
}
}
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
App.appComponent.inject(this)
val v = inflater?.inflate(R.layout.fragment_main, container, false)
return v
}
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
recyclerView.layoutManager = LinearLayoutManager(activity)
recyclerView.adapter = adapter
routesPresenter.getRoutes("18089")
}
override fun onSuccess(list: List<Route>) {
Log.d("MainFragment", "onSuccess")
adapter.setItems(list)
}
override fun onEmptyData() {
Log.d("MainFragment", "onEmpty")
}
override fun onError(e: Throwable) {
Log.e("MainFragment", "error ${e.message}" )
}
}`
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
lateinit property presenter has not been initialized through ...
This code should be in your fragment not in presenter because Presenter is a dependency for a Fragment. Share.
Read more >How to Check if a "lateinit" Variable Has Been Initialized or ...
If we don't initialize a lateinit variable before using it gives an error of “lateinit property has not been initialized”. You can check...
Read more >lateinit property androidInjector has not been initialized ...
In your application class you define an @Inject property, but you don't initialize it anywhere. What you need to do is: first declare...
Read more >Initializing lazy and lateinit variables in Kotlin - LogRocket Blog
Firstly, memory is not allocated to a lateinit property at the time of declaration. The initialization takes place later when you see fit....
Read more >Dagger2 + Kotlin: lateinit property has not been initialized
Android : Dagger2 + Kotlin: lateinit property has not been initialized [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have same issue, when i change orientation and call a funtion from presenter , kotlin throws : lateinit property Presenter has not been initialized , as you said i remove kapt plugin but it keep throwing error :
Do you use
kapt
in your gradle file for moxy compiler?