Leonids icon indicating copy to clipboard operation
Leonids copied to clipboard

NullPointerException

Open sanjaykumarm opened this issue 8 years ago • 8 comments

I am using com.plattysoft.leonids:LeonidsLib:1.3.1 version of this library and getting the following crashes from google play store :

java.lang.NullPointerException ! 1 at com.plattysoft.leonids.ParticleSystem.onUpdate(ParticleSystem.java:556) 2 at com.plattysoft.leonids.ParticleSystem.access$100(ParticleSystem.java:35) 3 at com.plattysoft.leonids.ParticleSystem$1.run(ParticleSystem.java:363) 4 at java.util.Timer$TimerImpl.run(Timer.java:284)

So can you please check it and resolve it?

sanjaykumarm avatar Apr 06 '16 14:04 sanjaykumarm

There is a lot of information missing here. Is this a crash on the Demo app on Play Store? If so, on which example? And what are the steps to replicate. Is it 100% replicable? I did re-check the examples right now and they seem to work fine.

If this is something you are getting on you own app, please post the code, you may be doing something wrong on the initialization of the Particle System.

plattysoft avatar Apr 08 '16 15:04 plattysoft

  • Is this a crash on the Demo app on Play Store? Ans : It is on play store.
  • It is not re-producible from my end but occasionally I am getting this error on google play store console and also getting this crash log on https://www.apteligent.com/

sanjaykumarm avatar Apr 11 '16 06:04 sanjaykumarm

That was not my question. The question was if the crash was happening on the Demos, not if your app was on the Play Store.

Without steps to replicate, there's nothing I can do.

plattysoft avatar Apr 11 '16 12:04 plattysoft

I have integrated the lib into my app and I have the same issue too. Not sure what's going on and here is the stacktrace from Crashlytics

Fatal Exception: java.lang.NullPointerException
       at com.plattysoft.leonids.ParticleSystem.onUpdate(ParticleSystem.java:556)
       at com.plattysoft.leonids.ParticleSystem.access$100(ParticleSystem.java:35)
       at com.plattysoft.leonids.ParticleSystem$2.onAnimationUpdate(ParticleSystem.java:445)
       at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1251)
       at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1175)
       at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1216)
       at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:637)
       at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:660)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
       at android.view.Choreographer.doCallbacks(Choreographer.java:574)
       at android.view.Choreographer.doFrame(Choreographer.java:543)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5372)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:970)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:786)
       at dalvik.system.NativeStart.main(NativeStart.java)

raymondctc avatar May 05 '16 11:05 raymondctc

@Smeet123 I probably figure out the reason for my case. I've been using a View.post() to force the animation to run on UI thread. I also have a destroy() call to .cancel() in ParticleSystem. It is very likely that the Runnable in my View.post() function executed after .cancel(), where mDrawingView will become null (check the code in onUpdate() and cancel()). See if that's your case too.

raymondctc avatar May 06 '16 01:05 raymondctc

@raymondctc Thank you so much for the solution, I will check it once I get time.

sanjaykumarm avatar May 06 '16 09:05 sanjaykumarm

May not be the cause of the reported NPE, but I can see a data race in ParticleTimerTask.run():

    if(mPs.get() != null) {
        ParticleSystem ps = mPs.get();

The two lines should be inverted:

    ParticleSystem ps = mPs.get();
    if(ps != null) {

smr99 avatar Dec 30 '16 05:12 smr99

The same

renyuzhuo avatar Nov 07 '17 06:11 renyuzhuo