Question

Since building a release version of my app with ProGuard enabled, my plot style is reset to the default and I see many warnings in Logcat informing me of unsupported parameters:

Error inflating XML: Setter for field "[...]" does not exist.

I've pinpointed this to be coming from AndroidPlot's Configurator, but haven't found any official ProGuard configuration for this project.

Was it helpful?

Solution

The mechanism through which AndroidPlot sets the configuration parameters relies heavily on reflection, and in that light I've decided it's useless to try to obfuscate anything inside this library:

-keep class com.androidplot.** { *; }

OTHER TIPS

In my case, I had been using proguard for debug builds and it worked fine. Then I ran a release build (which adds obfuscation to the proguard configuration) and that crashed when it tried to inflate XYPlot in a view.

Binary XML file line #12: Binary XML file line #12: Error inflating class com.androidplot.xy.XYPlot

To fix it, I just configured proguard to not obfuscate the names of any androidplot objects:

-keepnames class com.androidplot.**

That did not work for me yet. For troubleshooting I set the switches -dontshrink -dontoptimize -dontobfuscate in the first step (if that doesn't help, the reason is probably not to be found in ProGuard). After that you can step by step exclude single groups of classes, e.g. "-keep, includedescriptorclasses, includecode class my.path.to.R*{*;}". In my case the resource classes created by Android Studio had to be "-keep'ed":

-keep, includedescriptorclasses, includecode class com.androidplot.** {*;}

-keepclassmembers class **.R$* {
    public static <fields>;
}

see https://www.guardsquare.com/en/products/proguard/manual/examples

"We're keeping the static fields of referenced inner classes of auto-generated R classes, just in case your code is accessing those fields by introspection. Note that the compiler already inlines primitive fields, so ProGuard can generally remove all these classes entirely anyway (because the classes are not referenced and therefore not required)."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top