-
Notifications
You must be signed in to change notification settings - Fork 427
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
Error in access camera android. #500
Comments
I had the same issue, and with my limited understanding, it's because with plyer, the image is always saved in a path starting 'file://', which I don't think is accessible by your app (or something similar). If you edit this in the code within plyer/platforms/android/camera.py to 'content://', then this issue should be fixed, although another issue popped up when I did it (the images wouldn't be saved). |
Please post the full execution log, not just the error. |
This is the full log :D |
I fixed this issue by going to the player/platforms/Android/camera.py and
added the code
StrictMode = autoclass('android.os.StrictMode')
StrictMode.disableDeathOnUriFileExposure()
What this does is get the strict mode in Java and stop the program crashing
on file exposure. Contrary to before, you should leave 'file://' as it is.
…On Thu, 25 Apr 2019, 03:23 Jeferson Vinícius, ***@***.***> wrote:
04-24 23:21:46.915 2469 2586 I python : [WARNING] [Config ] Older configuration version detected (0 instead of 21)
04-24 23:21:46.915 2469 2586 I python : [WARNING] [Config ] Upgrading configuration in progress.
04-24 23:21:46.921 2469 2586 I python : [INFO ] [Logger ] Record log in /data/user/0/jerferson.developer.accesscamera.accesscamera/files/app/.kivy/logs/kivy_19-04-24_0.txt
04-24 23:21:46.921 2469 2586 I python : [INFO ] [Kivy ] v1.11.0.dev0, git-Unknown, 20190425
04-24 23:21:46.921 2469 2586 I python : [INFO ] [Python ] v3.7.1 (default, Apr 20 2019, 18:14:47)
04-24 23:21:46.921 2469 2586 I python : [Clang 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55
04-24 23:21:47.010 2469 2586 I python : [INFO ] [Factory ] 184 symbols loaded
04-24 23:21:47.512 2469 2586 I python : [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
04-24 23:21:47.618 2469 2586 I python : [INFO ] [Window ] Provider: sdl2
04-24 23:21:47.651 2469 2586 I python : [INFO ] [GL ] Using the "OpenGL ES 2" graphics system
04-24 23:21:47.653 2469 2586 I python : [INFO ] [GL ] Backend used <sdl2>
04-24 23:21:47.654 2469 2586 I python : [INFO ] [GL ] OpenGL version <b'OpenGL ES 3.2 ***@***.*** ***@***.***, I26dffed9a4) (Date:12/03/17)'>
04-24 23:21:47.654 2469 2586 I python : [INFO ] [GL ] OpenGL vendor <b'Qualcomm'>
04-24 23:21:47.654 2469 2586 I python : [INFO ] [GL ] OpenGL renderer <b'Adreno (TM) 506'>
04-24 23:21:47.654 2469 2586 I python : [INFO ] [GL ] OpenGL parsed version: 3, 2
04-24 23:21:47.655 2469 2586 I python : [INFO ] [GL ] Texture max size <16384>
04-24 23:21:47.655 2469 2586 I python : [INFO ] [GL ] Texture max units <16>
04-24 23:21:47.701 2469 2586 I python : [INFO ] [Window ] auto add sdl2 input provider
04-24 23:21:47.702 2469 2586 I python : [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
04-24 23:21:47.719 2469 2586 I python : [INFO ] [Text ] Provider: sdl2
04-24 23:21:48.179 2469 2586 I python : [WARNING] [Base ] Unknown <android> provider
04-24 23:21:48.179 2469 2586 I python : [INFO ] [Base ] Start application main loop
04-24 23:21:48.183 2469 2586 I python : [INFO ] [GL ] NPOT texture support is available
04-24 23:21:49.727 2469 2586 I python : [INFO ] [Base ] Leaving application in progress...
04-24 23:21:49.727 2469 2586 I python : Traceback (most recent call last):
04-24 23:21:49.728 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/app/main.py", line 28, in <module>
04-24 23:21:49.728 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/kivy/app.py", line 855, in run
04-24 23:21:49.729 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/kivy/base.py", line 502, in runTouchApp
04-24 23:21:49.729 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/kivy/core/window/window_sdl2.py", line 724, in mainloop
04-24 23:21:49.730 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/kivy/core/window/window_sdl2.py", line 459, in _mainloop
04-24 23:21:49.730 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/kivy/base.py", line 340, in idle
04-24 23:21:49.731 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/kivy/base.py", line 325, in dispatch_input
04-24 23:21:49.731 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/kivy/base.py", line 291, in post_dispatch_input
04-24 23:21:49.731 2469 2586 I python : File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
04-24 23:21:49.732 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/kivy/uix/behaviors/button.py", line 179, in on_touch_up
04-24 23:21:49.732 2469 2586 I python : File "kivy/_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
04-24 23:21:49.733 2469 2586 I python : File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
04-24 23:21:49.733 2469 2586 I python : File "kivy/_event.pyx", line 1098, in kivy._event.EventObservers._dispatch
04-24 23:21:49.734 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/kivy/lang/builder.py", line 64, in custom_callback
04-24 23:21:49.740 2469 2586 I python : File "/data/data/jerferson.developer.accesscamera.accesscamera/files/app/camera.kv", line 15, in <module>
04-24 23:21:49.741 2469 2586 I python : on_release: root.capture()
04-24 23:21:49.741 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/app/main.py", line 11, in capture
04-24 23:21:49.742 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/plyer/facades/camera.py", line 64, in take_picture
04-24 23:21:49.742 2469 2586 I python : File "/home/jeferson/BuildAPK/.buildozer/android/platform/build/build/python-installs/accesscamera/plyer/platforms/android/camera.py", line 26, in _take_picture
04-24 23:21:49.743 2469 2586 I python : File "jnius/jnius_export_class.pxi", line 1002, in jnius.jnius.JavaMultipleMethod.__call__
04-24 23:21:49.743 2469 2586 I python : File "jnius/jnius_export_class.pxi", line 734, in jnius.jnius.JavaMethod.__call__
04-24 23:21:49.744 2469 2586 I python : File "jnius/jnius_export_class.pxi", line 828, in jnius.jnius.JavaMethod.call_method
04-24 23:21:49.744 2469 2586 I python : File "jnius/jnius_utils.pxi", line 93, in jnius.jnius.check_exception
04-24 23:21:49.744 2469 2586 I python : jnius.jnius.JavaException: JVM exception occurred: file://IMG_20190424_232149.jpg exposed beyond app through ClipData.Item.getUri()
04-24 23:21:49.745 2469 2586 I python : Python for android ended.
This is the full log :D
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#500 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALI2S56C2TSLDAOH2VXQF33PSEI2DANCNFSM4GZB5S5Q>
.
|
I'm cannot use that, but, its think which resolve. But, I think too which should have an update in module. |
Any solution? I have the same error, but in the Android documentation I see that with the new APIs they use a fileprovider. Does anyone know how to fix it? Or some other way to use the camera? |
Might have found the solution. Basically, we need to use FileProvider class for the uri. For the most part just follow the instructions in here. https://developer.android.com/training/camera/photobasics.html These are the modification I made to camera.py:
I also added support-v4-24.1.1.aar, otherwise FileProvider class can't be found. Inside _take_picture function:
The AndroidManifest.tmpl.xml will also need to be modified according to the instructions in the link. But doing these will cause another problem where a duplication of the image will be saved to /DCIM/Camera |
Thank you very much |
@IHadAFish do you know if it always duplicates in DCIM, or is it camera-app-dependent? Thx! |
@dfrison01 There are some work arounds like alerting the user after they take the photo, or deleting the last image during the callback. |
Is the solution push to plyer??? |
Guys, what is the status of this? Is it part of Kivy upgrade 1.11.0? |
Where did you find the |
Not directly related to |
I am sure I have solved the problem. I am a kivy fan in China. Expect kivy to become more popular! |
any news ? |
i don't think p4a requires api >= 26, buildozer stills default to 21 which i think is the actual minimum https://github.com/kivy/buildozer/blob/master/buildozer/default.spec#L94 |
I can use camera in android API 27.
...
<!-- Android 2.3.3 -->
<uses-sdk android:minSdkVersion="{{ args.min_sdk_version }}" android:targetSdkVersion="{{ android_api }}" />
+ <uses-feature android:name="android.hardware.camera" />
+ <uses-feature android:name="android.hardware.camera.autofocus" />
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />
... ...
<activity android:name="{{ a }}"></activity>
{% endfor %}
+ <provider
+ android:name="android.support.v4.content.FileProvider"
+ android:authorities="<YOUR PACKAGE NAME>"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/file_paths"/>
+ </provider>
</application>
</manifest> NOTE: In you must put the full package of the app. It is package.domain concatenated with package.name provided in buildozer.spec. Example:
RESULT:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="Android/data/<YOUR PACKAGE NAME>/files/Pictures" />
</paths> Don't forget the package in this file too!
VERSIONS: I expect have helped. Sorry by my english, it don`t my native language. |
@jefersonvinicius There is a PR adding fileprovider to the p4a: kivy/python-for-android#1922 it will allow to do what you did manually above, by just specifying a path to your |
Wow, I didn't know that, it's great. Will it be available in future versions of the buildozer or is it already available? |
It would help if you can try to build apk with it and leave your review in the comment of that PR |
How dowload buildozer with this PR? |
It is not included in the buildozer yet, so after installing this p4a you should build your apk like this: p4a apk --private {app_root_dir} --version={app_version} --bootstrap=sdl2 --window --requirements=python3,kivy,openssl,sqlite3,pillow,pytz,sdl2,{requirements} --permission=CALL_PHONE --permission=INTERNET --permission=WRITE_EXTERNAL_STORAGE --permission=READ_EXTERNAL_STORAGE --orientation=portrait --dist-name test_my_build --fileprovider-paths=./fileprovider_paths.xml --package=org.example.mytest --name="mytest" --release |
@tshirtman I am not shure but here https://python-for-android.readthedocs.io/en/latest/quickstart/#installing-android-sdk I found :
and if I try to use API < 26 p4a do not compile |
is there is a fix for this problem? |
Use this p4a fork instead of bulldozer kivy/python-for-android#1922 |
Does anyone know how to correct this issue for android API level 30 (now required for the Play Store)? I'm having the same issue as the original post, however, when I try to apply the solution from @jefersonvinicius, the build fails with the exception that "Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0." I believe this is due to the support.aar file being specific to API 24, but the latest file I could find supported up to API 28 (with nothing available for 30). Using the bare camera.py file, I am able to get the native camera to pop up by changing the "file://" to "content://" but taking the photo doesn't actually save the file... I'd like to be able to save my image to storage but can't seem to get anything to work here... Any help or advice would be appreciated!
|
Obrigado @jefersonvinicius. Salvo meu projeto. |
@tinyleafgreens Have you solved your issue, I'am facing the same problem... |
I'am trying execute this:
But, I'm getting this error:
Any idea for resolve it?
Information:
API 27
Python 2.7
My buildozer.spec:
The text was updated successfully, but these errors were encountered: