Hi!
First of all, thank you for your work. Excellent library.
I have one little problem when exporting a signed apk with proguard. When opening chart views, animations are not happening.
If I turn off proguard, the animations start to work again.
I am testing in two Android 5.0.1 phones (Nexus 6 and Samsung S5)
Any idea?
Thanks in advance.
Pffff. I honestly do not have the slightest idea why this is (obviously) not working.
Does anyone else know something?
Can I see your Logcat @raulfdezhdez ??
In mine case the problem was due to incompatibility issues and i fixed it as:
ActionBarSherlock was failing to find a constructor "a(Activity,int)" using reflection.
ProGuard doesn't (can't) know this and has removed the constructor, because it appears unused in the code. You therefore have to explicitly tell ProGuard to keep it:
-keepclassmembers class * extends com.actionbarsherlock.ActionBarSherlock {
}
Mine is not generating any error log signing the apk or at runtime, and I am not using SherlockBar.
I have tried with the typical proguard rules, but no luck.
At the moment it is not a big problem and I am not in a hurry, so I will keep trying and if I find any clue or solution I will post it.
Thanks for the great library!
I had the same problem. I excluded the library from proguard adding this to proguard rules:
-dontwarn com.github.mikephil.**
-keep public class com.github.mikephil.** {
public protected *;
}
I'm not sure if there's a better approach but this works
@MarcSalvat this way MPAndroidChart become not obfuscated by proguard
Here is the reason. Original ChartAnimator.java contains this code
mAnimatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f);
/**
* This gets the y-phase that is used to animate the values.
*
* @return
*/
public float getPhaseY() {
return mPhaseY;
}
/**
* This modifys the y-phase that is used to animate the values.
*
* @param phase
*/
public void setPhaseY(float phase) {
mPhaseY = phase;
}
And this is a decompiled code, after proguard
package com.github.mikephil.charting.a;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.SuppressLint;
import android.os.Build.VERSION;
@SuppressLint({"NewApi"})
public class a
{
protected float a = 1.0F;
protected float b = 1.0F;
private ValueAnimator.AnimatorUpdateListener c;
private ObjectAnimator d;
public a() {}
public a(ValueAnimator.AnimatorUpdateListener paramAnimatorUpdateListener)
{
this.c = paramAnimatorUpdateListener;
}
public float a()
{
return this.a;
}
public void a(int paramInt)
{
if (Build.VERSION.SDK_INT < 11) {
return;
}
this.d = ObjectAnimator.ofFloat(this, "phaseX", new float[] { 0.0F, 1.0F });
this.d.setDuration(paramInt);
this.d.addUpdateListener(this.c);
this.d.start();
}
public float b()
{
return this.b;
}
}
You see that here is missing property "phaseX", thats why animation doesn't work. So we need to add only this line in the pro-guard file
-keep public class com.github.mikephil.charting.animation.* {
public protected *;
}
The code after decompile
package com.github.mikephil.charting.animation;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.SuppressLint;
import android.os.Build.VERSION;
@SuppressLint({"NewApi"})
public class ChartAnimator
{
private ValueAnimator.AnimatorUpdateListener a;
private ObjectAnimator b;
private ObjectAnimator c;
protected float mPhaseX = 1.0F;
protected float mPhaseY = 1.0F;
public ChartAnimator() {}
public ChartAnimator(ValueAnimator.AnimatorUpdateListener paramAnimatorUpdateListener)
{
this.a = paramAnimatorUpdateListener;
}
public void animateX(int paramInt)
{
if (Build.VERSION.SDK_INT < 11) {
return;
}
this.c = ObjectAnimator.ofFloat(this, "phaseX", new float[] { 0.0F, 1.0F });
this.c.setDuration(paramInt);
this.c.addUpdateListener(this.a);
this.c.start();
}
public void animateXY(int paramInt1, int paramInt2)
{
if (Build.VERSION.SDK_INT < 11) {
return;
}
this.b = ObjectAnimator.ofFloat(this, "phaseY", new float[] { 0.0F, 1.0F });
this.b.setDuration(paramInt2);
this.c = ObjectAnimator.ofFloat(this, "phaseX", new float[] { 0.0F, 1.0F });
this.c.setDuration(paramInt1);
if (paramInt1 > paramInt2) {
this.c.addUpdateListener(this.a);
}
for (;;)
{
this.c.start();
this.b.start();
return;
this.b.addUpdateListener(this.a);
}
}
public void animateY(int paramInt)
{
if (Build.VERSION.SDK_INT < 11) {
return;
}
this.b = ObjectAnimator.ofFloat(this, "phaseY", new float[] { 0.0F, 1.0F });
this.b.setDuration(paramInt);
this.b.addUpdateListener(this.a);
this.b.start();
}
public float getPhaseX()
{
return this.mPhaseX;
}
public float getPhaseY()
{
return this.mPhaseY;
}
public void setPhaseX(float paramFloat)
{
this.mPhaseX = paramFloat;
}
public void setPhaseY(float paramFloat)
{
this.mPhaseY = paramFloat;
}
}
Most helpful comment
Here is the reason. Original ChartAnimator.java contains this code
And this is a decompiled code, after proguard
You see that here is missing property "phaseX", thats why animation doesn't work. So we need to add only this line in the pro-guard file
The code after decompile