Skip to content
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

GPS example crashes #40

Closed
lipi opened this issue Mar 13, 2014 · 13 comments
Closed

GPS example crashes #40

lipi opened this issue Mar 13, 2014 · 13 comments

Comments

@lipi
Copy link
Contributor

lipi commented Mar 13, 2014

Trying to run the following code (from the docs):

from time import sleep
from plyer import gps

def print_locations(**kwargs):
    print 'lat: {lat}, lon: {lon}'.format(**kwargs)

gps.configure(on_location=print_locations)
gps.start()
sleep(5)
gps.stop()

However it crashes:

I/python  (29941): Initialize Python for Android
I/python  (29941): ['/data/data/org.test.gps/files/lib/python2.7/site-packages', '/data/data/org.test.gps/files/lib/site-python']
I/python  (29941): Android path ['/data/data/org.test.gps/files/lib/python27.zip', '/data/data/org.test.gps/files/lib/python2.7', '/data/data/org.test.gps/files/lib/python2.7/lib-dynload', '/data/data/org.test.gps/files/lib/python2.7/site-packages', '/data/data/org.test.gps/files']
I/python  (29941): Android kivy bootstrap done. __name__ is __main__
I/python  (29941): Run user program, change dir and execute main.py
I/python  (29941): Traceback (most recent call last):
I/python  (29941):   File "/home/lipi/git/repka2/android/main.py", line 7, in <module>
I/python  (29941):   File "/home/lipi/git/p4a/build/python-install/lib/python2.7/site-packages/plyer/facades.py", line 189, in configure
I/python  (29941):   File "/home/lipi/git/p4a/build/python-install/lib/python2.7/site-packages/plyer/platforms/android/gps.py", line 72, in _configure
I/python  (29941):   File "/home/lipi/git/p4a/build/python-install/lib/python2.7/site-packages/plyer/platforms/android/gps.py", line 20, in __init__
I/python  (29941):   File "jnius_proxy.pxi", line 31, in jnius.jnius.PythonJavaClass.__init__ (jnius/jnius.c:21301)
I/python  (29941):   File "jnius_proxy.pxi", line 182, in jnius.jnius.create_proxy_instance (jnius/jnius.c:23496)
I/python  (29941):   File "jnius_export_class.pxi", line 556, in jnius.jnius.JavaMethod.__call__ (jnius/jnius.c:17318)
I/python  (29941):   File "jnius_conversion.pxi", line 57, in jnius.jnius.populate_args (jnius/jnius.c:5405)
I/python  (29941):   File "jnius_utils.pxi", line 74, in jnius.jnius.check_assignable_from (jnius/jnius.c:3449)
I/python  (29941): jnius.jnius.JavaException: Invalid instance of 'org/jnius/NativeInvocationHandler' passed for a 'java/lang/reflect/InvocationHandler'
I/python  (29941): Python for android ended.
@trivedigaurav
Copy link
Member

Could you describe what you did in more detail? Running the code seems to work fine for me:

I/python  ( 5315): Starting audio thread
I/python  ( 5315): Initialize Python for Android
I/python  ( 5315): ['/data/data/org.test.gps/files/lib/python2.7/site-packages', '/data/data/org.test.gps/files/lib/site-python']
I/python  ( 5315): Android path ['/data/data/org.test.gps/files/lib/python27.zip', '/data/data/org.test.gps/files/lib/python2.7', '/data/data/org.test.gps/files/lib/python2.7/lib-dynload', '/data/data/org.test.gps/files/lib/python2.7/site-packages', '/data/data/org.test.gps/files']
I/python  ( 5315): Android kivy bootstrap done. __name__ is __main__
I/python  ( 5315): Run user program, change dir and execute main.py
I/python  ( 5315): Python for android ended.

@WardBenjamin
Copy link

Did you run this on Android? That could be the problem, as I think that
there problems running this on Windows.

On Thu, Mar 13, 2014 at 4:09 PM, trivedigaurav [email protected]:

Could describe what you did in more detail? Running the code seems to work
fine for me:

I/python ( 5315): Starting audio thread
I/python ( 5315): Initialize Python for Android
I/python ( 5315): ['/data/data/org.test.gps/files/lib/python2.7/site-packages', '/data/data/org.test.gps/files/lib/site-python']
I/python ( 5315): Android path ['/data/data/org.test.gps/files/lib/python27.zip', '/data/data/org.test.gps/files/lib/python2.7', '/data/data/org.test.gps/files/lib/python2.7/lib-dynload', '/data/data/org.test.gps/files/lib/python2.7/site-packages', '/data/data/org.test.gps/files']
I/python ( 5315): Android kivy bootstrap done. name is main
I/python ( 5315): Run user program, change dir and execute main.py
I/python ( 5315): Python for android ended.

Reply to this email directly or view it on GitHubhttps://github.com//issues/40#issuecomment-37580467
.

Benjamin Ward, Period 7 Psycho

@trivedigaurav
Copy link
Member

At this point the GPS facade is only available for Android. It will raise a NotImplemented Error on all other platforms.

@lipi
Copy link
Contributor Author

lipi commented Mar 14, 2014

It is running on Android, as you can see in the logcat output.

I used the latest (master) python-for-android, which in turn pulled the latest pyjnius I believe. Android version is 4.4.2.

@brousch
Copy link
Contributor

brousch commented Mar 14, 2014

What device and version of Android are you using?
On Mar 13, 2014 10:26 PM, "lipi" [email protected] wrote:

It is running on Android, as you can see in the logcat output.

I used the latest (master) python-for-android, which in turn pulled the
latest pyjnius I believe.

Reply to this email directly or view it on GitHubhttps://github.com//issues/40#issuecomment-37610071
.

@lipi
Copy link
Contributor Author

lipi commented Mar 15, 2014

Nexus 4 and Android 4.4.2 Python-for-andorid was built on Ubuntu 12.04, using NDK r9c and SDK 19.

Will try to reproduce it with different SDK level on different host and phone.

@trivedigaurav
Copy link
Member

Although I have not yet been able to reproduce the issue, it seems to be a Pyjnius issue and not necessarily specific to the GPS example. It occurs when calling the constructor to the PythonJavaClass. Here is another such reported issue on 4.4.2: kivy/pyjnius#92

@lipi
Copy link
Contributor Author

lipi commented Mar 16, 2014

Thanks for the tip, the example works after switching the runtime back to Dalvik.

I am closing this issue as it seems to be a duplicate of kivy/pyjnius#92

@lipi lipi closed this as completed Mar 16, 2014
@iamryanmoreno
Copy link

I am having trouble running the gps example in plyer.. I runned it but it is stuck with getting Click start to get GPS location updates. I runned it in kivy luncher with plyer and buildozer inside. can u please provide a screeshot of what should be seen after running the application and provide a clear step by step of running properly this program. PLease..............

@brousch
Copy link
Contributor

brousch commented Feb 13, 2015

I don't think Kivy Launcher has the Android permissions necessary to use
the GPS. You should compile an APK using buildozer and install it to your
device. Putting buildozer in your project does nothing.

On Fri, Feb 13, 2015 at 4:16 AM, iamryanmoreno [email protected]
wrote:

I am having trouble running the gps example in plyer.. I runned it but it
is stuck with getting Click start to get GPS location updates. I runned it
in kivy luncher with plyer and buildozer inside. can u please provide a
screeshot of what should be seen after running the application and provide
a clear step by step of running properly this program. PLease..............


Reply to this email directly or view it on GitHub
#40 (comment).

Ben Rousch
[email protected]
http://clusterbleep.net/

@iamryanmoreno
Copy link

can i get an apk of the plyer example for gps? i will install it in my phone because I am really curious about this python program?

@iamryanmoreno
Copy link

why is that when i runned the other examples, its working in my kivy launcher only that of gps is not. can someone provide another library for accessing gps in kivy?

@moonpyx
Copy link
Contributor

moonpyx commented Apr 20, 2016

hello, glad , download the GPS example plyer https://github.com/kivy/plyer/tree/master/examples/gps but for android in buildozer compile the application does not start when installed on my device with android 4.4.4 Error throws me NotImplementedError. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants