I have a extension method:
fun StoresClientFragment?.onClickButtonBack(){
this?.listener?.onStoresFragmentClickBtnMenu()
}
The app installs without any errors; but when the method is invoked at runtime it gives me the following error:
java.lang.NoSuchMethodError: No static method onClickButtonBack (Lcom/app/common_client/ui/fragment /stores/StoresClientFragment;) V in class Lcom/app/common_client/commons/CommonsAppTypeGroupKt; or its super classes (declaration of 'com.app.common_client.commons.CommonsAppTypeGroupKt' appears in /data/app/com.myapp.client-DWp0y3iNC3tsmBZkowlpfw==/base.apk!classes2.dex).
I have multidex enabled
In build.gradle
android {
defaultConfig {
multiDexEnabled = true
}
}
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
}
In Application class
class ApplicationClient : MultiDexApplication(){
}
In the Manifest
<application
android:name=".commons.application.ApplicationClient"
Note: I am using product flavors and modules, that method is in a src shared by some product flavors
sourceSets {
flavorA {
java.srcDirs + = "src/sharedFolder/java" //here is 'onClickButtonBack' method
}
flavorB {
java.srcDirs + = "src/sharedFolder/java"
}
}
Build -> Rebuild Project helped me. It seems to be a bug in Android Studio code caching
I have solved it, however I don't know why, the only thing I did was change the name of the file where the method was.
MyFile.kt by MyNewFile.kt
fun StoresClientFragment? .onClickButtonBack () {
this? .listener? .onStoresFragmentClickBtnMenu ()
}
I hope it helps someone who is experiencing the same thing, and I would also like if there is someone who knows why that has worked, share it, thank you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With