Error when trying to use the flash.on() method for android torch app

103 views
Skip to first unread message

Sulav Rai

unread,
Feb 28, 2023, 6:31:57 PM2/28/23
to Kivy users support
I am building an app that turns an Android flashlight on and off. I have debugged a lot but I do not know how to fix this error that shows up in the Logcat debugger.

jnius.jnius.JavaException: Cannot call instance method b'getParameters' on class b'android/hardware/Camera'
The relevant code snippit is below  

import json from kivy.app import App from kivy.core.window import Window # For the Background colour from kivy.lang import Builder from kivy.properties import ObjectProperty from kivy.uix.screenmanager import ScreenManager, Screen from datetime import datetime from plyer import flash from kivy import platform if platform == "android": from android.permissions import request_permissions, Permission request_permissions([Permission.CAMERA]) class LockMain(Screen): def torch(self): # Will turn the torch on flash.on()

Robert

unread,
Feb 28, 2023, 7:43:30 PM2/28/23
to Kivy users support
Plyer is not well maintained.
If it works, great. If not figure out how to do what you want with Pyjnius and the Android api.

Also, unrelated, calling permissions like that is a problem, See the second paragraph here
https://github.com/Android-for-Python/Android-for-Python-Users#user-permissions
Reply all
Reply to author
Forward
0 new messages