Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException #6

Open
lifenautjoe opened this issue Aug 28, 2019 · 4 comments
Open

java.lang.NullPointerException #6

lifenautjoe opened this issue Aug 28, 2019 · 4 comments

Comments

@lifenautjoe
Copy link

When calling

Thumbnails.getThumbnail(
                thumbnailFolder: tempDir,
                // creates the specified path if it doesnt exist
                videoFile: postVideo.path,
                imageType: ThumbFormat.JPEG,
                quality: 30)

I get

I/FilePicker(15864): Absolute file path:/storage/emulated/0/DCIM/Camera/VID_20190828_120040.mp4
D/EGL_emulation(15864): eglCreateContext: 0xdd073820: maj 3 min 0 rcv 3
D/EGL_emulation(15864): eglMakeCurrent: 0xdd073820: ver 3 0 (tinfo 0xe4852ee0)
D/EGL_emulation(15864): eglMakeCurrent: 0xdea85a20: ver 3 0 (tinfo 0xc5535e60)
D/EGL_emulation(15864): eglMakeCurrent: 0xdd073820: ver 3 0 (tinfo 0xe4852ee0)
W/System.err(15864): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
W/System.err(15864): 	at com.asapjay.thumbnails.ThumbnailsPlugin.userDirectory(ThumbnailsPlugin.java:126)
W/System.err(15864): 	at com.asapjay.thumbnails.ThumbnailsPlugin.buildThumbnail(ThumbnailsPlugin.java:64)
W/System.err(15864): 	at com.asapjay.thumbnails.ThumbnailsPlugin.onMethodCall(ThumbnailsPlugin.java:49)
W/System.err(15864): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
W/System.err(15864): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
W/System.err(15864): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
W/System.err(15864): 	at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(15864): 	at android.os.MessageQueue.next(MessageQueue.java:326)
W/System.err(15864): 	at android.os.Looper.loop(Looper.java:160)
W/System.err(15864): 	at android.app.ActivityThread.main(ActivityThread.java:6669)
W/System.err(15864): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err(15864): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err(15864): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
@rogerhaw
Copy link

same here

@kamleshwebtech
Copy link

Any solution, you found, please share. Thanks.

@kamleshwebtech
Copy link

I am still getting below issue:

W/System.err( 2412): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
W/System.err( 2412): 	at com.asapjay.thumbnails.ThumbnailsPlugin.userDirectory(ThumbnailsPlugin.java:138)
W/System.err( 2412): 	at com.asapjay.thumbnails.ThumbnailsPlugin.buildThumbnail(ThumbnailsPlugin.java:64)
W/System.err( 2412): 	at com.asapjay.thumbnails.ThumbnailsPlugin.onMethodCall(ThumbnailsPlugin.java:49)
W/System.err( 2412): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
W/System.err( 2412): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
W/System.err( 2412): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:738)
W/System.err( 2412): 	at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err( 2412): 	at android.os.MessageQueue.next(MessageQueue.java:329)
W/System.err( 2412): 	at android.os.Looper.loop(Looper.java:142)
W/System.err( 2412): 	at android.app.ActivityThread.main(ActivityThread.java:6375)
W/System.err( 2412): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 2412): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
W/System.err( 2412): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)

and my function is as:

getVideoUrlToThumbUrl(videoPathUrl) async {
    if (await getFileType(videoPathUrl) != CONST_APP_FILE_TYPE_VIDEO) {
      return '';
    }
    final docDirectory = await getApplicationDocumentsDirectory();
    String videothumbnailsPath = docDirectory.path + '/videothumbnails';

    // String videothumbnailsPath = CONST_APP_ED_VIDEO_PATH;

    File file = new File(videoPathUrl);
    String fileName = file.path.split('/').last;
    fileName = fileName.replaceFirst('.mp4', '.png');
    var isThumbExists =
        await io.File(videothumbnailsPath + '/' + fileName).exists();
    String vdoPath = '';
    if (isThumbExists == false) {
      vdoPath = await Thumbnails.getThumbnail(
          thumbnailFolder: videothumbnailsPath,
          videoFile: videoPathUrl,
          imageType: ThumbFormat.PNG,
          quality: 10);
    } else {
      vdoPath = videothumbnailsPath + '/' + fileName;
    }
    return vdoPath;
  }

Any solution, please share. Thanks a lot.

@marianoarga
Copy link

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants