Ivan-Mark Debono
Ivan-Mark Debono

Reputation: 16320

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 my proguard.cfg file?

Upvotes: 3

Views: 2344

Answers (1)

Tema Green
Tema Green

Reputation: 101

I had a similar problem and that works for me:

-keepclassmembers class yourPackageName.YourClassName{
   *;
}

YourClassName and yourPackageName are names of class and package of class that you pass to the function fromJson.

Upvotes: 3

Related Questions