找不到 GraphViewSeries 类
我正在尝试使用 GraphView 库在我的应用程序上显示图表。代码非常简单:
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);
}
}
这个错误:
E/dalvikvm(1224): Could not find class 'com.jjoe64.graphview.GraphView $GraphViewSeries', referenced from method pizio.prova.it.ProvaGraphViewActivity.onCreate
然后这个致命异常:
java.lang.NoClassDefFoundError: com.jjoe64.graphview.GraphView$GraphViewSeries
E/AndroidRuntime(1224): at pizio.prova.it.ProvaGraphViewActivity.onCreate(ProvaGraphViewActivity.java:22)
就是我得到的全部。为什么它无法到达我已经导入的类?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许你可以尝试去项目>属性>进出口。检查 GraphView Jar 文件并将其向上移动。完成后,点击“确定”并清理项目,然后运行。
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.
将其添加到项目的 libs 文件夹中。对我来说效果很好。开发人员实际上也假设仅将其复制到库 ^^
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 ^^
我遇到了同样的问题。也许,您可能会在 bulid 文件中使用 graphview-4.x.jar 扩展名。您正在尝试从“GraphView”扩展导入“GraphviewSeries”。但这会给你带来错误。
由于从 GraphView 3.1 迁移到 4.0,您需要遵循最新格式或者使用 graphview3.x.jar 文件来导入 GraphViewSeries。
如需进一步了解,请参阅以下链接:
http://www .android-graphview.org/documentation/migration-from-31-to-40
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