Search code examples
androidkotlinsingletonnoclassdeffounderror

NoClassDefFoundError for singleton kotlin android?


I create an arr of my library module and use it in another application.

On one of the singleton class from my aar I get NoClassDefFoundError for its usage

This is my singleton class

object SharedPrefTask {

fun doSomeWork() {
    /////
}
}

This is the class where I use the singleton

class ConfigController(val mContext: Context) {
private var prefTask: SharedPrefTask = SharedPrefTask

fun fetchConfig() {
    val configs = prefTask.doSomeWork()
}
}

Is there something which is wrong here? I get the exception

Fatal Exception: java.lang.NoClassDefFoundError: <clinit> failed for class m0.g; see exception in other thread
   at b.a.<init>(ConfigController.kt:2)

Solution

  • The issue was due obsfucation from the obsfucation of proguard Adding the rule helped resolve this

    -keeppackagenames com.exaple.**