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

App crashes on android when using plyer camera #522

Closed
mokhoo opened this issue Jul 2, 2017 · 9 comments
Closed

App crashes on android when using plyer camera #522

mokhoo opened this issue Jul 2, 2017 · 9 comments

Comments

@mokhoo
Copy link
Contributor

mokhoo commented Jul 2, 2017

Hi all,

I am trying to build an apk package using buildozer. The app uses kivy plyer camera. The app starts normally on the phone and crashes when trying to access the camera. I couldn't find the exact cause, after some searching I realized that maybe it is related to the new python-for-android package. Below you can find the code.

main.py

from kivy.app import App #for the main app
from kivy.uix.floatlayout import FloatLayout #the UI layout
from kivy.uix.label import Label #a label to show information
from plyer import camera #object to read the camera

class UI(FloatLayout):#the app ui
	def __init__(self, **kwargs):
		super(UI, self).__init__(**kwargs)
		self.lblCam = Label(text="Click to take a picture!") #create a label at the center
		self.add_widget(self.lblCam) #add the label at the screen

	def  on_touch_down(self, e):
		camera.take_picture('/storage/sdcard0/example.jpg', self.done) #Take a picture and save at this location. After will call done() callback

	def done(self, e): #receive e as the image location
		self.lblCam.text = e; #update the label to the image location
        
class Camera(App): #our app
	def build(self):
		ui = UI()# create the UI
		return ui #show it

	def on_pause(self):
		#when the app open the camera, it will need to pause this script. So we need to enable the pause mode with this method
		return True

	def on_resume(self):
		#after close the camera, we need to resume our app.
		pass

Camera().run() #start our app
        

buildozer.spec:

  
[app]
title = Python Camera
package.name = camera
package.domain = com.wordpress.bytedebugger
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
version = 1.3
requirements = python2,kivy, plyer
fullscreen = 1
android.permissions = CAMERA,WRITE_EXTERNAL_STORAGE
[buildozer]
log_level = 2

The app originally from:
http://blog.rhesoft.com/2014/07/19/python-for-android-tutorial-2-taking-a-picture/

@bengdryan
Copy link

bengdryan commented Feb 25, 2018

Adding "android" to the buildozer requirements worked for me... as I found out after hours of screwing around with plyer code.

@inclement
Copy link
Member

Thanks for the note, maybe the plyer recipe should depend on the android module, although it's not strictly a hard dependency.

@Shamsyuhada
Copy link

Shamsyuhada commented Mar 14, 2018

@benjamingeorgedanielryan adding "android" to the buildozer requirements --- do you mean in the buildozer.spec?

@bengdryan
Copy link

@Shamsyuhada Yes, add to the requirements list in the buildozer.spec alongside python2, kivy etc in the example above.

@blinhares
Copy link

i have the same problem but put "android" on the requirements don't work.

@vyasdeep668
Copy link

I also have same problem, putting "android" in .spec file isn't working!!!! App crashes

@AndreMiras
Copy link
Member

This isn't a buildozer issue to me.
And @vyasdeep668 can't say anything without build log and run log

@codinghedgehog-python
Copy link

Is there any resolution to this ? I came here with the same problem. What do I need to provide to get some assistance ?

@inclement
Copy link
Member

@codinghedgehog-python Please feel free to open a bug on the plyer repository, but it's unlikely anyone will pick it up soon. If you'd like help debugging it yourself, I suggest asking on the kivy discord channels.

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

8 participants