I'm working on a Kivy app which needs to upload a file to S3 using `boto3` but fails in the JSON `decoder.py` when trying to load the `endpoint` model and establish a `client` connection. This works fine locally running on `16.04` but fails after compiling with `buildozer` and running on `Lollipop 5.1.1`.
Buildozer log.
I/python (27222): [INFO ] [Base ] Leaving application in progress...
I/python (27222): Traceback (most recent call last):
I/python (27222): File "/build/phytogp/android/app/main.py", line 10, in <module>
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivy/app.py", line 828, in run
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivy/base.py", line 504, in runTouchApp
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 663, in mainloop
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 405, in _mainloop
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivy/base.py", line 342, in idle
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivy/base.py", line 327, in dispatch_input
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivy/base.py", line 293, in post_dispatch_input
I/python (27222): File "kivy/_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:8191)
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivymd/ripplebehavior.py", line 68, in on_touch_up
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivymd/button.py", line 314, in on_touch_up
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivymd/button.py", line 206, in on_touch_up
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivy/uix/behaviors/button.py", line 179, in on_touch_up
I/python (27222): File "kivy/_event.pyx", line 714, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:8146)
I/python (27222): File "kivy/_event.pyx", line 1225, in kivy._event.EventObservers.dispatch (kivy/_event.c:14035)
I/python (27222): File "kivy/_event.pyx", line 1109, in kivy._event.EventObservers._dispatch (kivy/_event.c:12816)
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/kivy/lang/builder.py", line 64, in custom_callback
I/python (27222): File "<string>", line 31, in <module>
I/python (27222): File "/build/phytogp/android/app/views/widgets/checkedin.py", line 112, in finish_button_on_release
I/python (27222): File "/build/phytogp/android/app/views/widgets/checkedin.py", line 144, in upload_report
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/boto3/__init__.py", line 83, in client
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/boto3/session.py", line 263, in client
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/botocore/session.py", line 826, in create_client
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/botocore/session.py", line 701, in get_component
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/botocore/session.py", line 897, in get_component
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/botocore/session.py", line 186, in create_default_resolver
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/botocore/loaders.py", line 132, in _wrapper
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/botocore/loaders.py", line 420, in load_data
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/site-packages/botocore/loaders.py", line 175, in load_file
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/json/__init__.py", line 339, in loads
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/json/decoder.py", line 366, in decode
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/json/decoder.py", line 382, in raw_decode
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/json/scanner.py", line 38, in _scan_once
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/json/decoder.py", line 195, in JSONObject
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/json/scanner.py", line 40, in _scan_once
I/python (27222): File "/build/phytogp/android/platform/build/dists/phytogp/private/lib/python2.7/json/decoder.py", line 262, in JSONArray
I/python (27222): ValueError: Expecting , delimiter: line 63 column 29 (char 1666)
Connection command causing the issue is:
main.py
client = boto3.client(
's3',
aws_access_key_id='IVEGOTTHEKEY',
aws_secret_access_key='IVEGOTTHESECRET',
region_name='ap-southeast-2',
)
Looking at the stack trace it's falling over trying to load `endpoints.json` with the `botocore.loader` at the `load_file` line in the `load_data` method:
`BOTOCORE_ROOT` is where it should pick up these files. When deployed to Android `BOTOCORE_ROOT` is `/data/data/com.phyto.phytogp/files/app/lib/python2.7/site-packages/botocore` which is an empty app folder.
The stack trace doesn't show that it failed to find the file by raising `DataNotFoundError` which suggests it found the file but couldn't parse it hence the `json/decoder` error.
I've tried copying those files to `BOTOCORE_ROOT` and forcing versions of `boto3` and dependencies to the same used locally but no good. APK is built on the [Buildozer_VM][1] with the following spec:
SSL comms are working fine when deployed and talking to `SparkPost` and another 3rd party API.
I'm out of ideas so any help would be great. Thanks