Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got lateinit property mainPresenter has not been initialized in Kotlin #31

Closed
lectricas opened this issue Oct 20, 2016 · 4 comments
Closed

Comments

@lectricas
Copy link

lectricas commented Oct 20, 2016

hey, I have this code:

class MainActivity : MvpAppCompatActivity(), MainViewInterface, AnkoLogger {

    @InjectPresenter
    lateinit var mainPresenter: MainPresenter

    val recyclerView: RecyclerView by bindView(R.id.track_list)
    val fab: FloatingActionButton by bindView(R.id.fab)
    val cLayout: CoordinatorLayout by bindView(R.id.main_coordinator)

    val realm: Realm = Realm.getDefaultInstance()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        MyApplication.graph.inject(this)
        recyclerView.layoutManager = LinearLayoutManager(this)
        mainPresenter.loadAllTracks() //error here
    }

ViewState:

@StateStrategyType(value = AddToEndSingleStrategy::class) //not sure about this thing
interface MainViewInterface : MvpView {
    fun successLoadingTracks(tracks: List<Track>)
}

Presenter

@InjectViewState
class MainPresenter : MvpPresenter<MainViewInterface>() {

    fun loadAllTracks() {
        viewState.successLoadingTracks(ArrayList())
    }
}

And I get this error when trying to access presenter var. Kotlin plugin is up to date.

@lectricas
Copy link
Author

lectricas commented Oct 20, 2016

SOLUTION

forgot to include
kapt 'com.arello-mobile:moxy-compiler:0.4.2'

this thing. Now it's working.

@xanderblinov
Copy link
Collaborator

Try 1+ library version ;-)

@lectricas
Copy link
Author

Also , this error might happen when you forgot to extend MoxyFragment \ Activity.

@romangromov
Copy link

Also, try to Clean/Rebuild project - this works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants