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

Example app not working #17

Closed
valkrypton opened this issue Apr 15, 2024 · 2 comments
Closed

Example app not working #17

valkrypton opened this issue Apr 15, 2024 · 2 comments
Labels

Comments

@valkrypton
Copy link

valkrypton commented Apr 15, 2024

Hello,

I cloned the git repo and ran the example app on my phone without making any changes and I got this error message:

E/MethodChannel#ultralytics_yolo(27995):`` Failed to handle method call
E/MethodChannel#ultralytics_yolo(27995): java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.camera.lifecycle.ProcessCameraProvider.unbindAll()' on a null object reference
E/MethodChannel#ultralytics_yolo(27995): at com.ultralytics.ultralytics_yolo.CameraPreview.bindPreview(CameraPreview.java:79)
E/MethodChannel#ultralytics_yolo(27995): at com.ultralytics.ultralytics_yolo.CameraPreview.setCameraFacing(CameraPreview.java:97)
E/MethodChannel#ultralytics_yolo(27995): at com.ultralytics.ultralytics_yolo.MethodCallHandler.setLensDirection(MethodCallHandler.java:260)
E/MethodChannel#ultralytics_yolo(27995): at com.ultralytics.ultralytics_yolo.MethodCallHandler.onMethodCall(MethodCallHandler.java:95)
E/MethodChannel#ultralytics_yolo(27995): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/MethodChannel#ultralytics_yolo(27995): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/MethodChannel#ultralytics_yolo(27995): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#ultralytics_yolo(27995): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#ultralytics_yolo(27995): at android.os.Handler.handleCallback(Handler.java:958)
E/MethodChannel#ultralytics_yolo(27995): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#ultralytics_yolo(27995): at android.os.Looper.loopOnce(Looper.java:230)
E/MethodChannel#ultralytics_yolo(27995): at android.os.Looper.loop(Looper.java:319)
E/MethodChannel#ultralytics_yolo(27995): at android.app.ActivityThread.main(ActivityThread.java:8893)
E/MethodChannel#ultralytics_yolo(27995): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#ultralytics_yolo(27995): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
E/MethodChannel#ultralytics_yolo(27995): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
E/flutter (27995): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'void androidx.camera.lifecycle.ProcessCameraProvider.unbindAll()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.camera.lifecycle.ProcessCameraProvider.unbindAll()' on a null object reference
E/flutter (27995): at com.ultralytics.ultralytics_yolo.CameraPreview.bindPreview(CameraPreview.java:79)
E/flutter (27995): at com.ultralytics.ultralytics_yolo.CameraPreview.setCameraFacing(CameraPreview.java:97)
E/flutter (27995): at com.ultralytics.ultralytics_yolo.MethodCallHandler.setLensDirection(MethodCallHandler.java:260)
E/flutter (27995): at com.ultralytics.ultralytics_yolo.MethodCallHandler.onMethodCall(MethodCallHandler.java:95)
E/flutter (27995): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/flutter (27995): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/flutter (27995): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/flutter (27995): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter (27995): at android.os.Handler.handleCallback(Handler.java:958)
E/flutter (27995): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (27995): at android.os.Looper.loopOnce(Looper.java:230)
E/flutter (27995): at android.os.Looper.loop(Looper.java:319)
E/flutter (27995): at android.app.ActivityThread.main(ActivityThread.java:8893)
E/flutter (27995): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (27995): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
E/flutter (27995): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
E/flutter (27995): )
E/flutter (27995): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
E/flutter (27995): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter (27995):
E/flutter (27995): #2 UltralyticsYoloCameraController.toggleLensDirection (package:ultralytics_yolo/camera_preview/ultralytics_yolo_camera_controller.dart:48:5)
E/flutter (27995):
E/flutter (27995):

Help would be appreciated!!

@pderrenger
Copy link
Member

Hello! 😊 It looks like you've encountered a NullPointerException related to the camera lifecycle in the Ultralytics example app. This is typically due to the ProcessCameraProvider not being initialized before its usage.

Please make sure your app has the correct permissions for camera usage in your AndroidManifest.xml. Additionally, verify that your device is compatible and that no other app is using the camera resource.

If the issue persists, consider initializing the ProcessCameraProvider in your activity or fragment's lifecycle properly before attempting to bind or unbind the camera. Here is an example snippet that might help:

ProcessCameraProvider cameraProvider = ... // get instance here
if(cameraProvider != null) {
    cameraProvider.unbindAll(); // This is where the error points.
    // Further processing...
}

For more detailed information on managing the camera lifecycle, please refer to the Android developer documentation on camera X libraries.

Should this not resolve the issue, please provide us with more details about your setup (device model, Android version, etc.), and we'll be glad to look further into it. Remember, checking the Ultralytics Docs at https://docs.ultralytics.com for additional guidance might also be helpful.

Happy coding!

Copy link

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

@github-actions github-actions bot added the Stale label May 17, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants