Search code examples
androidnoclassdeffounderrorfatal-error

Could not find class GraphViewSeries


I'm trying to show graphs on my App using GraphView library. The code is very simple:

package pizio.prova.it;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;

import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.GraphView.GraphViewData;
import com.jjoe64.graphview.GraphView.GraphViewSeries;
import com.jjoe64.graphview.LineGraphView;

public class ProvaGraphViewActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        // init example series data  
        GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] {  
              new GraphViewData(1, 2.0d)  
              , new GraphViewData(2, 1.5d)  
              , new GraphViewData(3, 2.5d)  
              , new GraphViewData(4, 1.0d)  
        });  


        GraphView graphView = new LineGraphView(  
              this // context  
              , "GraphViewDemo" // heading  
        );  
        graphView.addSeries(exampleSeries); // data  

        LinearLayout layout = (LinearLayout) findViewById(R.id.graphLayout);  
        layout.addView(graphView);

    }
}

This error:

E/dalvikvm(1224): Could not find class 'com.jjoe64.graphview.GraphView            $GraphViewSeries', referenced from method pizio.prova.it.ProvaGraphViewActivity.onCreate

And then this fatal exception:

java.lang.NoClassDefFoundError: com.jjoe64.graphview.GraphView$GraphViewSeries
E/AndroidRuntime(1224):     at pizio.prova.it.ProvaGraphViewActivity.onCreate(ProvaGraphViewActivity.java:22)

is all that I get. Why can't it reach the classes I've already imported?


Solution

  • Perhaps you could try and go to Porject > Properties > Import and Export. Check the GraphView Jar file and move it up. Once this is done hit OK and clean the project then run.