Android Kotlin: “overrides nothing” error appears on instantiateItem() function of PagerAdapter

I just began learning Kotlin for work and one of the first errors I encountered is “overrides nothing” pointing at the overrides of the function instantiateItem() for my PagerAdapter

The function/method signature was like this:

override fun instantiateItem(parent: ViewGroup?, position: Int): Any {

To fix the error, I simply removed the question mark from the arguments so that it looked like:

override fun instantiateItem(parent: ViewGroup, position: Int): Any {

Voila! Error gone and the swipe view that needed the PagerAdapter worked.

Reference: Sudden “overrides nothing” errors appear, no recent change to Kotlin build version

Catzie

A Filipino who is a mobile & web developer on weekdays, and a baker on weekends. When I have time to spare, I blog, play video games, watch series (usually anime), cook dishes, draw, or spend a little time with pets. When I have the rare luxury of time, I get to travel and record song covers too! Follow on Twitter: @catzie

Leave a Reply

Your email address will not be published. Required fields are marked *