question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

First time crash for permission issues

See original GitHub issue

Basically what seems to happen, is runtime permission is requested thanks to kivy-garden/garden.zbarcam#30, but it’s not somewhat a blocking call and in the meantime the camera is being accessed before the user chose to accept that permission. So we either need to make sure the code is blocking or somehow postpone the access to the camera until the permission is given. See stacktrace:

03-04 14:39:29.917 28875 29157 I python  : Android kivy bootstrap done. __name__ is __main__
03-04 14:39:29.917 28875 29157 I python  : AND: Ran string
03-04 14:39:29.917 28875 29157 I python  : Run user program, change dir and execute entrypoint
03-04 14:39:30.195 28875 29157 I python  : [WARNING] [Config      ] Older configuration version detected (0 instead of 21)
03-04 14:39:30.195 28875 29157 I python  : [WARNING] [Config      ] Upgrading configuration in progress.
03-04 14:39:30.206 28875 29157 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/com.github.andremiras.zbarcamdemo/files/app/.kivy/logs/kivy_19-03-04_0.txt
03-04 14:39:30.206 28875 29157 I python  : [INFO   ] [Kivy        ] v1.11.0.dev0, git-8a443a9, 20190303
03-04 14:39:30.206 28875 29157 I python  : [INFO   ] [Python      ] v3.7.1 (default, Mar  3 2019, 17:30:25)
03-04 14:39:30.207 28875 29157 I python  : [Clang 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55
03-04 14:39:30.343 28875 29157 I python  : [INFO   ] [Factory     ] 184 symbols loaded
03-04 14:39:31.039 28875 29157 I python  : [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
03-04 14:39:31.360 28875 29157 I python  : [INFO   ] [Window      ] Provider: sdl2
03-04 14:39:31.443 28875 29157 I python  : [INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
03-04 14:39:31.445 28875 29157 I python  : [INFO   ] [GL          ] Backend used <sdl2>
03-04 14:39:31.446 28875 29157 I python  : [INFO   ] [GL          ] OpenGL version <b'OpenGL ES 3.2 v1.r12p1-04bet0.1bb9662be2ebee934dcbd7265c794a91'>
03-04 14:39:31.447 28875 29157 I python  : [INFO   ] [GL          ] OpenGL vendor <b'ARM'>
03-04 14:39:31.447 28875 29157 I python  : [INFO   ] [GL          ] OpenGL renderer <b'Mali-T830'>
03-04 14:39:31.448 28875 29157 I python  : [INFO   ] [GL          ] OpenGL parsed version: 3, 2
03-04 14:39:31.451 28875 29157 I python  : [INFO   ] [GL          ] Texture max size <8192>
03-04 14:39:31.451 28875 29157 I python  : [INFO   ] [GL          ] Texture max units <16>
03-04 14:39:31.541 28875 29157 I python  : [INFO   ] [Window      ] auto add sdl2 input provider
03-04 14:39:31.545 28875 29157 I python  : [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
03-04 14:39:32.198 28875 29157 I python  : [INFO   ] [Camera      ] Provider: android
03-04 14:39:32.224 28875 29157 I python  : [INFO   ] [Text        ] Provider: sdl2
03-04 14:39:32.702 28875 29157 I python  :  Traceback (most recent call last):
03-04 14:39:32.703 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/lang/builder.py", line 623, in _apply_rule
03-04 14:39:32.703 28875 29157 I python  :    File "kivy/weakproxy.pyx", line 33, in kivy.weakproxy.WeakProxy.__setattr__
03-04 14:39:32.704 28875 29157 I python  :    File "kivy/properties.pyx", line 483, in kivy.properties.Property.__set__
03-04 14:39:32.704 28875 29157 I python  :    File "kivy/properties.pyx", line 817, in kivy.properties.ListProperty.set
03-04 14:39:32.705 28875 29157 I python  :    File "kivy/properties.pyx", line 524, in kivy.properties.Property.set
03-04 14:39:32.705 28875 29157 I python  :    File "kivy/properties.pyx", line 579, in kivy.properties.Property.dispatch
03-04 14:39:32.706 28875 29157 I python  :    File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
03-04 14:39:32.706 28875 29157 I python  :    File "kivy/_event.pyx", line 1120, in kivy._event.EventObservers._dispatch
03-04 14:39:32.707 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/uix/camera.py", line 103, in _on_index
03-04 14:39:32.707 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/core/camera/camera_android.py", line 42, in __init__
03-04 14:39:32.708 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/core/camera/__init__.py", line 70, in __init__
03-04 14:39:32.708 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/core/camera/camera_android.py", line 49, in init_camera
03-04 14:39:32.709 28875 29157 I python  :    File "jnius/jnius_export_class.pxi", line 1002, in jnius.jnius.JavaMultipleMethod.__call__
03-04 14:39:32.709 28875 29157 I python  :    File "jnius/jnius_export_class.pxi", line 733, in jnius.jnius.JavaMethod.__call__
03-04 14:39:32.710 28875 29157 I python  :    File "jnius/jnius_export_class.pxi", line 899, in jnius.jnius.JavaMethod.call_staticmethod
03-04 14:39:32.710 28875 29157 I python  :    File "jnius/jnius_utils.pxi", line 93, in jnius.jnius.check_exception
03-04 14:39:32.711 28875 29157 I python  :  jnius.jnius.JavaException: JVM exception occurred: Fail to connect to camera service
03-04 14:39:32.711 28875 29157 I python  :
03-04 14:39:32.711 28875 29157 I python  :  During handling of the above exception, another exception occurred:
03-04 14:39:32.711 28875 29157 I python  :
03-04 14:39:32.711 28875 29157 I python  :  Traceback (most recent call last):
03-04 14:39:32.712 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/app/main.py", line 9, in <module>
03-04 14:39:32.712 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/app.py", line 829, in run
03-04 14:39:32.713 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/app/zbarcam/zbarcam.py", line 145, in build
03-04 14:39:32.713 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/lang/builder.py", line 400, in load_string
03-04 14:39:32.714 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/lang/builder.py", line 584, in _apply_rule
03-04 14:39:32.714 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/lang/builder.py", line 469, in apply
03-04 14:39:32.715 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/lang/builder.py", line 585, in _apply_rule




03-04 14:39:32.715 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/lang/builder.py", line 584, in _apply_rule
03-04 14:39:32.716 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/lang/builder.py", line 469, in apply
03-04 14:39:32.716 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/lang/builder.py", line 630, in _apply_rule
03-04 14:39:32.717 28875 29157 I python  :  kivy.lang.builder.BuilderException: Parser: File "<inline>", line 28:
03-04 14:39:32.717 28875 29157 I python  :  ...
03-04 14:39:32.717 28875 29157 I python  :       26:
03-04 14:39:32.717 28875 29157 I python  :       27:    id: camera
03-04 14:39:32.718 28875 29157 I python  :  >>   28:    resolution: 640, 480 # 1920, 1080
03-04 14:39:32.718 28875 29157 I python  :       29:    allow_stretch: True
03-04 14:39:32.718 28875 29157 I python  :       30:
03-04 14:39:32.718 28875 29157 I python  :  ...
03-04 14:39:32.718 28875 29157 I python  :  JavaException: JVM exception occurred: Fail to connect to camera service
03-04 14:39:32.719 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/lang/builder.py", line 623, in _apply_rule
03-04 14:39:32.719 28875 29157 I python  :    File "kivy/weakproxy.pyx", line 33, in kivy.weakproxy.WeakProxy.__setattr__
03-04 14:39:32.719 28875 29157 I python  :    File "kivy/properties.pyx", line 483, in kivy.properties.Property.__set__
03-04 14:39:32.719 28875 29157 I python  :    File "kivy/properties.pyx", line 817, in kivy.properties.ListProperty.set
03-04 14:39:32.719 28875 29157 I python  :    File "kivy/properties.pyx", line 524, in kivy.properties.Property.set
03-04 14:39:32.720 28875 29157 I python  :    File "kivy/properties.pyx", line 579, in kivy.properties.Property.dispatch
03-04 14:39:32.720 28875 29157 I python  :    File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
03-04 14:39:32.720 28875 29157 I python  :    File "kivy/_event.pyx", line 1120, in kivy._event.EventObservers._dispatch
03-04 14:39:32.720 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/uix/camera.py", line 103, in _on_index
03-04 14:39:32.720 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/core/camera/camera_android.py", line 42, in __init__
03-04 14:39:32.721 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/core/camera/__init__.py", line 70, in __init__
03-04 14:39:32.721 28875 29157 I python  :    File "/home/andre/workspace/garden.zbarcam/.buildozer/android/platform/build/build/python-installs/zbarcamdemo/kivy/core/camera/camera_android.py", line 49, in init_camera
03-04 14:39:32.721 28875 29157 I python  :    File "jnius/jnius_export_class.pxi", line 1002, in jnius.jnius.JavaMultipleMethod.__call__
03-04 14:39:32.721 28875 29157 I python  :    File "jnius/jnius_export_class.pxi", line 733, in jnius.jnius.JavaMethod.__call__
03-04 14:39:32.721 28875 29157 I python  :    File "jnius/jnius_export_class.pxi", line 899, in jnius.jnius.JavaMethod.call_staticmethod
03-04 14:39:32.722 28875 29157 I python  :    File "jnius/jnius_utils.pxi", line 93, in jnius.jnius.check_exception
03-04 14:39:32.722 28875 29157 I python  :
03-04 14:39:32.722 28875 29157 I python  : Python for android ended.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Mar 4, 2019

@darosior that will block the main thread, that might cause other problems. use a (main-thread event/non-threaded) timer callback, we should probably add an example for that to the python-for-android docs since this is a common issue

(I mainly haven’t added one because I don’t use kivy and I’m not familiar with it’s timer callback scheduling API)

0reactions
AndreMirascommented, Aug 11, 2019

https://github.com/kivy/python-for-android/pull/1818 was merged, so we should probably build that feature on top of it

Read more comments on GitHub >

github_iconTop Results From Across the Web

App crashes right after asking for location permission for the ...
After a lot of tries I am still getting the following error. java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION ...
Read more >
Application Crashes On First Time Permission Ask - B4X
When the application first run it crashes on asking for permission. After allowing it next time it runs OK. I understand the the...
Read more >
Bluetooth permissions - Android Developers
System permissions dialog, asking the user to grant an app permission to discover, advertise, and connect to nearby devices. If your app targets...
Read more >
App Center Crashes for iOS - Microsoft Learn
App Center Crashes will automatically generate a crash log every time your app crashes. The log is first written to the device's storage...
Read more >
How to fix Kali NetHunter app crashing every time?
The first step in fixing a bug or bypassing the problem is understanding why and what happens. I would recommend to check logcat...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found