RealtimeBlurView icon indicating copy to clipboard operation
RealtimeBlurView copied to clipboard

NPE on a null object reference

Open afiqiqmal opened this issue 7 years ago • 1 comments

classpath 'com.android.tools.build:gradle:3.0.1'

defaultConfig {
        renderscriptTargetApi 25
        renderscriptSupportModeEnabled true
}
buildToolsVersion = '27.0.3'
minSdkVersion = 21
targetSdkVersion = 25
compileSdkVersion = 27

This happend after i upgrade to gradle 3.0

Below Stacktrace

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v8.renderscript.Allocation.copyFrom(android.graphics.Bitmap)' on a null object reference
at com.github.mmin18.widget.RealtimeBlurView.blur(RealtimeBlurView.java:206)
at com.github.mmin18.widget.RealtimeBlurView$1.onPreDraw(RealtimeBlurView.java:249)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2082)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1134)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6050)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860)
at android.view.Choreographer.doCallbacks(Choreographer.java:672)
at android.view.Choreographer.doFrame(Choreographer.java:608)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846)
at android.os.Handler.handleCallback(Handler.java:742)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5527)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)

afiqiqmal avatar Jan 25 '18 02:01 afiqiqmal

I had to copy your entire code RealtimeBlurView to escaping the error

and try and catch this line of code

try {
      RealTimeBlurViewV2.this.blur(RealTimeBlurViewV2.this.mBitmapToBlur, RealTimeBlurViewV2.this.mBlurredBitmap);
       if (redrawBitmap || RealTimeBlurViewV2.this.mDifferentRoot) {
                        RealTimeBlurViewV2.this.invalidate();
       }
} catch (Exception e) {
       e.printStackTrace();
       RealTimeBlurViewV2.this.release();
}

afiqiqmal avatar Jan 25 '18 06:01 afiqiqmal