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?
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:
- Right click your project - go to build path - select Configure build path
- go to the "Order and Export" tab
- Check the "achartengine-1.0.0.jar box and then single click its name
- 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...)
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"!
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.
The answer from 'Shine' worked with the addition of removing import of android.R
from PieChartBuilder
and removing two @Overrides
from PieChartBuilder
and XY_ChartBuilder
before Eclipse would agree to compile.
You need simply to add your jar files to the Libraries folder. It should work fine.
来源:https://stackoverflow.com/questions/10433847/achartengine-demo-compiling-but-runtime-error