IllegalArgumentException:半径必须> 0

我正在使用AChartEngine库在视图寻呼机中devise条形图和饼图。 当我从条形图滚动到饼图时,应用程序崩溃。 崩溃报告如下。

FATAL EXCEPTION: main java.lang.IllegalArgumentException: radius must be > 0 at android.graphics.RadialGradient.<init>(RadialGradient.java:58) at org.achartengine.chart.PieChart.draw(PieChart.java:112) at org.achartengine.GraphicalView.onDraw(GraphicalView.java:168) at android.view.View.draw(View.java:11120) at android.view.ViewGroup.drawChild(ViewGroup.java:2901) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.ViewGroup.drawChild(ViewGroup.java:2899) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.ViewGroup.drawChild(ViewGroup.java:2899) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.View.draw(View.java:11123) at android.support.v4.view.ViewPager.draw(ViewPager.java:2157) at android.view.ViewGroup.drawChild(ViewGroup.java:2901) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.ViewGroup.drawChild(ViewGroup.java:2899) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.ViewGroup.drawChild(ViewGroup.java:2899) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.ViewGroup.drawChild(ViewGroup.java:2899) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.ViewGroup.drawChild(ViewGroup.java:2899) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.View.draw(View.java:11123) at android.widget.FrameLayout.draw(FrameLayout.java:450) at android.view.ViewGroup.drawChild(ViewGroup.java:2901) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.ViewGroup.drawChild(ViewGroup.java:2899) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.ViewGroup.drawChild(ViewGroup.java:2899) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at android.view.View.draw(View.java:11123) at android.widget.FrameLayout.draw(FrameLayout.java:450) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2276) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2210) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1816) at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2628) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4517) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) at dalvik.system.NativeStart.main(Native Method) 

任何帮助解决这个问题将是可观的。

Solutions Collecting From Web of "IllegalArgumentException:半径必须> 0"

如果您在Android L(5.0)上遇到此问题,我注意到GradientDrawable不接受“%”后缀。 所以相反,我已经使用了“%p”后缀,它工作。 此外,我需要改变我的荒谬的高价值(80000%)与正常值(80%p),现在看来是正确的。

所以,我已经创build了一个“drawable-v21”文件夹(Android L将从中绘制drawable),复制了包含渐变的形状xml,并更改了这一行:

 android:gradientRadius="80000%" 

有了这个

 android:gradientRadius="80%p" 

在我的情况下,我添加了android:gradientRadius="30dp"

最后那个dp在一些设备上也抛出了相同的exception。

离开它android:gradientRadius="30"或使用@ radu122的答案