I am facing an issue where my android code is throwing NoSuchFieldError only on some Samsung devices. From what I understand, NoSuchFieldError usually occurs due to usage of different library version at compile and run time. However, in this case, why would a private field result in this error? If it helps, I use proguard and this class is used by injection via dagger.
java.lang.NoSuchFieldError: No field mIsRegistered of type Z in class Lcom/my/package/MyClass; or its superclasses (declaration of 'Lcom/my/package/MyClass' appears in base.apk!classes11.dex)
at Lcom/my/package/MyClass.myMethod(MyClass.java:97)
at Lcom/my/package/MyClass.myMethod(MyClass1.java:36)
My code basically looks like this:
public class MyClass extends BroadcastReceiver implement MyInterface {
private final Object mLock = new Object();
private volatile boolean mIsRegistered = false;
public MyClass() {
}
@Override
public void myMethod() {
synchronized (mLock) {
if (mIsRegistered) {
// do something
}
}
}
}
My proguard config is similar to:
-keep class com.my.package.** {*;}