Proguard on Android and using Json

I have a class:

public class ObjectSettings 
{
public TextureRegion Region;
public ObjectType ObjectType;
public ObjectAffect ObjectAffect;
public String Name;
public int MinimumInterval = 0;
public int MaximumInterval = 0;
public Vector2 Center;

public static ObjectSettings load(int number) {
    ObjectSettings settings = null;
    try {
        Json json = new Json();     
        settings = json.fromJson(ObjectSettings.class, Integer.toString(number) + 
        Constants.FILE_EXT_JSON));
    } finally {};
    return settings;
}
}

      

When I use proguard I get the following error:

02-19 08:48:56.709: E/AndroidRuntime(29042): com.badlogic.gdx.utils.SerializationException: Error reading file: data/settings/0.json

      

and

02-19 08:48:56.709: E/AndroidRuntime(29042): Caused by: com.badlogic.gdx.utils.SerializationException: Field not found: ObjectType (com.myname.mapapp.data.ObjectSettings)

      

What do I need to add to the proguard.cfg file?

+3


source to share


1 answer


I had a similar problem and this works for me:

-keepclassmembers class yourPackageName.YourClassName{
   *;
}

      



YourClassName

and yourPackageName

are the class and package names of the class you are passing to the fromJson function.

+3


source







All Articles