achartengine demo compiling, but runtime error

2020-02-12 03:27发布

问题:

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?

回答1:

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...)



回答2:

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:

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:

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.



回答5:

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