Android ошибка перед построением данных: Invalid Region.Op - разрешены только INTERSECT и DIFFERENCE - PullRequest
1 голос
/ 26 мая 2020

Мне нужно было обновить мое приложение до SDK 28, и ошибки отображались во всех действиях, вызывающих построение графиков как java .lang.IllegalArgumentException: Invalid Region.Op - разрешены только INTERSECT и DIFFERENCE следовать методу:

 @Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    this.chart.draw(canvas, chartArea);
}

Это приложение использует org.afree.chart.AFreeChart, и требуется следующий класс:

public class GraphView extends View {

private AFreeChart chart;
private RectShape chartArea;
private Handler mHandler;

public GraphView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mHandler = new Handler();
    chartArea = new RectShape();
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    chartArea.setWidth(w);
    chartArea.setHeight(h);
}

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    this.chart.draw(canvas, chartArea);
}

public void setChart(AFreeChart chart) {
    this.chart = chart;
}

public void repaint() {
    mHandler.post(new Runnable() {
        public void run() {
            invalidate();
        }
    });
}

}

См. стек ниже :

Process: com.xyz.app, PID: 17118
java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
    at android.graphics.Canvas.checkValidClipOp(Canvas.java:779)
    at android.graphics.Canvas.clipRect(Canvas.java:826)
    at org.afree.chart.AFreeChart.draw(AFreeChart.java:1169)
    at org.afree.chart.AFreeChart.draw(AFreeChart.java:1061)
    at com.xyz.app.tools.GraphView.onDraw(GraphView.java:37)
    at android.view.View.draw(View.java:20207)
    at android.view.View.updateDisplayListIfDirty(View.java:19082)
    at android.view.View.draw(View.java:19935)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.updateDisplayListIfDirty(View.java:19073)
    at android.view.View.draw(View.java:19935)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.draw(View.java:20210)
    at android.view.View.updateDisplayListIfDirty(View.java:19082)
    at android.view.View.draw(View.java:19935)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.updateDisplayListIfDirty(View.java:19073)
    at android.view.View.draw(View.java:19935)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.updateDisplayListIfDirty(View.java:19073)
    at android.view.View.draw(View.java:19935)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.draw(View.java:20210)
    at com.android.internal.policy.DecorView.draw(DecorView.java:780)
    at android.view.View.updateDisplayListIfDirty(View.java:19082)
    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686)
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692)
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:801)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:3311)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3115)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2484)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
    at android.view.Choreographer.doCallbacks(Choreographer.java:761)
    at android.view.Choreographer.doFrame(Choreographer.java:696)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
...