当我使用https://github.com/plattysoft/Leonids中的代码实现一些效果时。有时它会发生崩溃。消息是:
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2911)
at android.view.View.getDisplayList(View.java:12841)
at android.view.View.getDisplayList(View.java:12890)
at android.view.View.draw(View.java:13640)
at android.view.ViewGroup.drawChild(ViewGroup.java:3050)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2912)
at android.view.View.getDisplayList(View.java:12841)
at android.view.View.getDisplayList(View.java:12890)
at android.view.View.draw(View.java:13640)
at android.view.ViewGroup.drawChild(ViewGroup.java:3050)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2912)
at android.view.View.getDisplayList(View.java:12841)
at android.view.View.getDisplayList(View.java:12890)
at android.view.View.draw(View.java:13640)
at android.view.ViewGroup.drawChild(ViewGroup.java:3050)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2912)
at android.view.View.getDisplayList(View.java:12841)
at android.view.View.getDisplayList(View.java:12890)
at android.view.View.draw(View.java:13640)
at android.view.ViewGroup.drawChild(ViewGroup.java:3050)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2912)
at android.view.View.draw(View.java:13947)
at android.widget.FrameLayout.draw(FrameLayout.java:467)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2247)
at android.view.View.getDisplayList(View.java:12846)
at android.view.View.getDisplayList(View.java:12890)
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1249)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2567)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2434)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2236)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1211)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5039)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
at android.view.Choreographer.doCallbacks(Choreographer.java:579)
at android.view.Choreographer.doFrame(Choreographer.java:548)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5433)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)
at dalvik.system.NativeStart.main(Native Method)
没有任何有用的消息。我甚至使用这样的try catch块:
try
{
configureEmiter(emiter, gravity);
startEmiting(particlesPerSecond);
}catch (NullPointerException e){
}
catch (Exception e){
}
但它不起作用。 有什么想法解决这个问题吗?请帮助我,非常感谢。
答案 0 :(得分:1)
我的代码中有一些错误。我已删除视图导致问题。感谢您的关注和答案。