achartengine demo compiling, but runtime error

2020-02-12 03:16发布

I followed demo instructions on page http://www.achartengine.org/content/goodies.html

i successfully imported the demo project, but every chart give throws a NoClassDefFoundError at runtime, similar to this:

java.lang.NoClassDefFoundError:
org.achartengine.model.XYMultipleSeriesDataset

achartengine-1.0.0.jar is on build path, and it is reported under 'Referenced Libraries'. I guess this is a newbie problem, but I decided to report it since I just imported the demo project 'as is' and tried to run it on my phone.

Do I need other steps, not listed on 'goodies' page?

5条回答
别忘想泡老子
2楼-- · 2020-02-12 03:29

Remind to change the "lib" directory to "libs" first !

Then CHECK the box of achartengine-1.0.0.jar and move it over the Android Dependencies in the "Configure build path" - "Order and Export" tab"!

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2020-02-12 03:34

The error (NoClassDefFoundError) you are seeing is runtime error. Referenced library solves only compile time error not runtime error. Add those jars to lib folder of your project. Those jars should be available at runtime also.

查看更多
我命由我不由天
4楼-- · 2020-02-12 03:39

I found a good answer on google groups, tested it and it seems to be working:

The only thing that I have ever came across in this case is the export of the jar ... if that makes sense.

In Eclipse:

  1. Right click your project - go to build path - select Configure build path
  2. go to the "Order and Export" tab
  3. Check the "achartengine-1.0.0.jar box and then single click its name
  4. move it up so its right below the Android dependancies (sometimes this can make a difference if you have multiple Jars)

click ok then clean your project. (Project -> Clean...)

查看更多
ら.Afraid
5楼-- · 2020-02-12 03:42

The answer from 'Shine' worked with the addition of removing import of android.R from PieChartBuilder and removing two @Overrides from PieChartBuilder and XY_ChartBuilderbefore Eclipse would agree to compile.

查看更多
我命由我不由天
6楼-- · 2020-02-12 03:45

You need simply to add your jar files to the Libraries folder. It should work fine.

查看更多
登录 后发表回答