Java AChartEngine在添加点和平移后崩溃

Java AChartEngine在添加点和平移后崩溃,java,android,charts,nullpointerexception,achartengine,Java,Android,Charts,Nullpointerexception,Achartengine,我正在用构建一个Android应用程序,并且出现了奇怪的错误 在我向已经建立的图表中添加新点并触摸/平移图表后,我在折线图(XYChart)中得到一个NullPointerException。GetSeriesAndPointForScreenCoordination(Point),其中GraphicalView的变量oldX和oldY被发现为空。这些变量在GraphicalView.onTouchEvent()中设置,但显然没有被调用 在初始化我的图形时,是否有方法手动触发onTouchEve

我正在用构建一个Android应用程序,并且出现了奇怪的错误

在我向已经建立的图表中添加新点并触摸/平移图表后,我在
折线图(XYChart)中得到一个
NullPointerException
。GetSeriesAndPointForScreenCoordination(Point)
,其中
GraphicalView
的变量
oldX
oldY
被发现为空。这些变量在
GraphicalView.onTouchEvent()
中设置,但显然没有被调用

在初始化我的图形时,是否有方法手动触发onTouchEvent(),或者是否有解决此错误的方法

以下是我的图表设置代码:

mChartView = ChartFactory.getLineChartView(this, mDataset, mRenderer);
mChartView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();
        double[] xy = mChartView.toRealPoint(0);
        if (seriesSelection == null) {
            Toast.makeText(viewer.this,
                    "No chart element was clicked",
                    Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(
                    viewer.this,
                    "Chart element clicked", Toast.LENGTH_SHORT)
                    .show();
        }
    }
});
以下是我如何添加新的点:

protected class NewPoints extends AsyncTask<Double, Void, Void> {
    @Override
    protected Void doInBackground(Double... values) {
        mCurrentSeries.add(values[0], values[1]); // x, y

        if (mChartView != null) {
            mChartView.repaint();
        }
        return null;
    }
}
更新1:

我重新编译了Acharengine源代码,调试表明错误发生在以下方法中:

public SeriesSelection getSeriesAndPointForScreenCoordinate(final Point screenPoint) {
    if (clickableAreas != null)
      for (int seriesIndex = clickableAreas.size() - 1; seriesIndex >= 0; seriesIndex--) {
        // series 0 is drawn first. Then series 1 is drawn on top, and series 2
        // on top of that.
        // we want to know what the user clicked on, so traverse them in the
        // order they appear on the screen.
        int pointIndex = 0;
        if (clickableAreas.get(seriesIndex) != null) {
          RectF rectangle;
          for (ClickableArea area : clickableAreas.get(seriesIndex)) {
            rectangle = area.getRect(); // EXCEPTION HERE: area is null
            if (rectangle != null && rectangle.contains(screenPoint.getX(), screenPoint.getY())) {
              return new SeriesSelection(seriesIndex, pointIndex, area.getX(), area.getY());
            }
            pointIndex++;
          }
        }
      }
    return super.getSeriesAndPointForScreenCoordinate(screenPoint);
  }
异常在
rectangle=area.getRect()处抛出行,其中
区域
为空,因为
可点击区域。get(0)
以某种方式返回空可点击区域的集合


我将尝试通过检查clickableArea是否为空来修补此问题,但这回避了一个问题:我添加的点是否正确?空指针异常可能是由于AcharEngine jar文件有时停止使用而不再使用。因此,您应该通过右键单击项目来检查构建路径上的jar文件。从中选择选项

    Order and Export->choose your jar files->click up and down button. 

它可以用来打开项目中使用的jar文件。

空指针异常可能是由AcharEngine jar文件有时在不再使用时停止使用而引起的。因此,您应该通过右键单击项目来检查构建路径上的jar文件。从中选择选项

    Order and Export->choose your jar files->click up and down button. 

它可以用于打开项目中使用的jar文件。

根据stacktrace,异常发生在下面XYChart.java代码的第二行(如果我的源代码有匹配的行号):

for(ClickableArea:clickableAreas.get(seriesIndex)){

rectangle=area.getRect();//根据stacktrace,异常发生在XYChart.java的以下代码的第二行(如果我的源代码有匹配的行号):

for(ClickableArea:clickableAreas.get(seriesIndex)){

矩形=区域。getRect();//你能发布指向剩余异常的日志吗?你得到答案了吗?@Venkatesh:我已经编辑了问题并添加了相关的日志输出。你能发布指向剩余异常的日志吗?你得到答案了吗?@Venkatesh:我已经编辑了问题并添加了相关的日志输出。P请检查一下。如果不是你要找的,请告诉我我会进一步帮助你。AChartEngine在
订单和导出
下启用。你是说我也应该将其移到列表的顶部吗?我认为订单与依赖关系无关。请检查一下。如果不是你要找的,请告诉我我我会进一步帮助你。AChartEngine在
Order and Export
下启用。您是说我也应该将其移到列表的顶部吗?我认为顺序对于依赖项并不重要。感谢您的回答-我已使用调试结果更新了问题。感谢您的回答-我已使用调试结果更新了问题。
    Order and Export->choose your jar files->click up and down button. 
for (ClickableArea area : clickableAreas.get(seriesIndex)) {
    rectangle = area.getRect();  // <--- Exception here!
    if (rectangle != null && rectangle.contains(screenPoint.getX(), screenPoint.getY())) {
        return new SeriesSelection(seriesIndex, pointIndex, area.getX(), area.getY());
    }
    pointIndex++;
}