To convert a string to a resource, I use the following method.

public static int getResId(String variableName, Class<?> c) { try { Field idField = c.getDeclaredField(variableName); return idField.getInt(idField); } catch (Exception e) { e.printStackTrace(); return -1; } } 

When using ProGuard, this method does not work! What needs to be added to proguard.cfg?

    1 answer 1

    Add to proguard.cfg a label that does not obfuscate class (s) that are passed as a parameter to your int getResId(String variableName, Class<?> c) method int getResId(String variableName, Class<?> c)