well, this is becoming a pain to generate my release apk and make it work
so, literally I build the apk succefully but I have an error whit a method
Caused by: java.lang.NoSuchMethodException: <init> [interface com.myapp.domain.login.LoginRepo]
Now, I have in my proGuard the followin
-keep class com.myapp.domain.** {*;}
-keep interface com.myapp.domain.** {*;}
Now, I dont know why this error is happening since I'm keeping these interfaces and this classes, the error line that told me about this problem is here
class LoginVMFactory(val repo:LoginRepo):ViewModelProvider.Factory {
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return modelClass.getConstructor(LoginRepo::class.java).newInstance(repo)
}
}
I also have this LoginVMFactory inside my domain package, so I'm also keeping this class, I really dont know why this is happening just before release, the app works well without proGuard but I dont want it to be 50mb, instead with proGuard it shrinks down to just 10
thanks
The problem is that we need to also keep viewmodels when offuscating, so this line will keep all classes that extends from ViewModel
-keep public class * extends androidx.lifecycle.ViewModel {*;}
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