A strange field appears in the studio Android

I have a pojo class

run this code

 Field[] fields = clazz.getDeclaredFields(); 

I got a field under the Android Studio IDE:

its type is the interface com.android.tools.fd.runtime.IncrementalChange its name is $ change

My version of Android Studio 2.0 Preview 4

the pojo class, which I redid myself, did not have a change field $

when i run the code in eclipse it works fine.

Where did the field come from? how can i avoid this field, is there any setting in Android Studio ?

+6
source share
3 answers

Instead of disabling instant start, we can solve this problem using a synthetic modifier check. 'com.android.tools.fd.runtime.IncrementalChange' is synthetic, so we can check if the field is synthetic using the isSynthetc method.

 Field[] fields = objClass.getFields(); for (Field field : fields) { String name = field.getName(); Object value; if(field.isSynthetic()){ continue; } //add your code here } 
+8
source

Most likely, this field has been added to support the Instant Run feature added in Android Studio 2.0, and will not appear if you disable Instant Run.

+9
source

I think diordna responds better with link .install run - this is a new feature of Android Studio, I will not close it.

I use the JsonTool link in my sdk library when I run my application with androidStudio2.2 JsonTooll.objectToJson (), give me a bad json String, I am adding code
if (name.contains("this$") || field.isSynthetic()) continue;

solve it

0
source

All Articles