NotImplementedError when using Plyer on Android via Pydroid 3 to access GPS/Accelerometer

145 Views Asked by At

I want to be able to access the hardware components (e.g. GPS, accelerometer) of my Samsung Galaxy A12 (software version currently updated to Android 12) using the Python library Plyer. I'm running my Python code via Pydroid 3.

I've tried using Plyer for accessing GPS AND for accessing accelerometer, but regardless of what component I try to access, the code does not work, whether for GPS or for accelerometer.

Here is an example of my code where I try to access my Android's accelerometer:

from plyer import accelerometer

def print_acceleration(acceleration):
    print("X: ", acceleration.x, "Y: ", acceleration.y, "Z: ", acceleration.z)

accelerometer.enable()
accelerometer.bind(on_acceleration = print_acceleration)
acceleration.acceleration

This code (and my code for accessing GPS as well) gives me the following error:

Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/plyer/utils.py", line 96, in _ensure_obj mod = import(module, fromlist='.') File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/plyer/platforms/android/init.py", line 2, in from jnius import autoclass File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/jnius/init.py", line 42, in from .reflect import * # noqa File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/jnius/reflect.py", line 20, in class Class(with_metaclass(MetaJavaClass, JavaClass)): File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/six.py", line 872, in new return meta(name, resolved_bases, d) File "jnius/jnius_export_class.pxi", line 119, in jnius.jnius.MetaJavaClass.new SystemError: NULL result without error in PyObject_Call Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), main.dict) File "", line 191, in File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/plyer/facades/accelerometer.py", line 55, in enable self._enable() File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/plyer/facades/accelerometer.py", line 69, in _enable raise NotImplementedError() NotImplementedError

[Program finished]

I do know that Plyer requires Pyjnius, but I have Pyjnius installed in this environment, so I don't think that is the source of the issue. Can anybody help me with this? I have no idea what might be going wrong. I checked the documentation and it seems that the syntax of my code is correct.

Thanks!

0

There are 0 best solutions below