So my project is calling Kotlin file to Java :
This is the error message (Run Time Error) I got:
java.lang.UnsupportedOperationException: Required method instantiateItem was not overridden
this is my app gradle
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
....
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
....
implementation "org.jetbrains.kotlin:kotlin-stdlib"
}
my project gradle looks:
buildscript {
ext.kotlin_version = '1.2.61'
repositories {
...
}
dependencies {
....
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
and last, this is my kotlin code,
class SwipeAdapter : PagerAdapter {
....
...
override fun instantiateItem(container: ViewGroup?, position: Int):Any {
.....
....
return super.instantiateItem(container, position)
}
.....
}
(I tried to change it to java.lang.Object but of course got a compilation error, it must be type of Any for Kotlin)
called on java file:
PagerAdapter sa= new SwipeAdapter(someArgs);