2

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?

animuson
  • 50,765
  • 27
  • 132
  • 142
Patrizio G
  • 342
  • 3
  • 12
  • 1
    Here is the answer to your question: http://stackoverflow.com/questions/2247998/noclassdeffounderror-eclipse-and-android – Dimath Apr 09 '12 at 04:49

3 Answers3

3

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.

wdziemia
  • 1,359
  • 1
  • 13
  • 17
2

add it into the libs Folder in your Project. for me it worked well. The developer actually also assumes to copy it to libs only ^^

eee
  • 21
  • 1
0

I faced the same problem. Perhaps, it may happen that you could be using graphview-4.x.jar extension in your bulid file. You are trying to import ' GraphviewSeries ' from ' GraphView ' extension. But that would throw you a error.

Since there is a migration from GraphView 3.1 to 4.0 you need to follow the latest format or rather use graphview3.x.jar file to import GraphViewSeries.

For further understanding please refer to the following link:

http://www.android-graphview.org/documentation/migration-from-31-to-40