找不到 GraphViewSeries 类

发布于 2025-01-05 01:21:26 字数 1831 浏览 1 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

氛圍 2025-01-12 01:21:26

也许你可以尝试去项目>属性>进出口。检查 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.

一指流沙 2025-01-12 01:21:26

将其添加到项目的 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 ^^

荒人说梦 2025-01-12 01:21:26

我遇到了同样的问题。也许,您可能会在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文