i have a pojo
class
run this code
Field[] fields = clazz.getDeclaredFields();
i got a field under Android Studio
IDE :
its type is interface com.android.tools.fd.runtime.IncrementalChange
its name is $change
My Android Studio version is 2.0 Preview 4
the pojo class which i definded by myself didn't have $change field
when i run the code in eclipse, it works normal.
where did the field come from?
how can i avoid this field , is there some setting in Android Studio
?
Instead of turning off instant run we can resolve this issue by utilising synthetic modifier check. 'com.android.tools.fd.runtime.IncrementalChange' is synthetic so we can check whether the field is synthetic using isSynthetc method.
Field[] fields = objClass.getFields();
for (Field field : fields) {
String name = field.getName();
Object value;
if(field.isSynthetic()){
continue;
}
//add your code here
}
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