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

Notification.notify crashes android app #296

Closed
Fogapod opened this issue Mar 9, 2017 · 20 comments
Closed

Notification.notify crashes android app #296

Fogapod opened this issue Mar 9, 2017 · 20 comments

Comments

@Fogapod
Copy link

Fogapod commented Mar 9, 2017

I created my kivy app using android_new buildozer toolchain. (It works fine on old android toolchain)
My app get crashed when plyer's notification.notify() is called.
There is no exception. So I can't catch it.

  • Kivy: master
  • Plyer: 1.2.4
  • Python: 2.7
  • Platform: android
@sumitmadhwani
Copy link
Contributor

Hi @Fogapod , can you please share the logs which are generated when you run your app?

@Fogapod
Copy link
Author

Fogapod commented Mar 11, 2017

@Malverick , unfortunantely, there's nothing useful in kivy logs:

[INFO   ] Logger: Record log in /data/user/0/org.vkbot_testing/files/app/.kivy/logs/kivy_17-03-11_1.txt
[INFO   ] Kivy: v1.9.2.dev0, git-Unknown, 20170311
[INFO   ] Python: v2.7.2 (default, Mar 10 2017, 17:52:09) 
[GCC 4.8]
[INFO   ] Factory: 194 symbols loaded
[DEBUG  ] Cache: register <kv.lang> with limit=None, timeout=None
[DEBUG  ] Cache: register <kv.image> with limit=None, timeout=60
[DEBUG  ] Cache: register <kv.atlas> with limit=None, timeout=None
[INFO   ] Image: Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[DEBUG  ] Cache: register <kv.texture> with limit=1000, timeout=60
[DEBUG  ] Cache: register <kv.shader> with limit=1000, timeout=3600
[INFO   ] OSC: using <thread> for socket
[INFO   ] Window: Provider: sdl2
[INFO   ] GL: Using the "OpenGL ES 2" graphics system
[DEBUG  ] GL: glShaderBinary is not available
[INFO   ] GL: Backend used <gl>
[INFO   ] GL: OpenGL version <OpenGL ES 3.0 [email protected] AU@ (GIT@I741a3d36ca)>
[INFO   ] GL: OpenGL vendor <Qualcomm>
[INFO   ] GL: OpenGL renderer <Adreno (TM) 330>
[INFO   ] GL: OpenGL parsed version: 3, 0
[INFO   ] GL: Texture max size <4096>
[INFO   ] GL: Texture max units <16>
[DEBUG  ] Shader: Fragment compiled successfully
[DEBUG  ] Shader: Vertex compiled successfully
[DEBUG  ] ImageSDL2: Load </data/user/0/org.vkbot_testing/files/app/lib/python2.7/site-packages/kivy/data/glsl/default.png>
[INFO   ] Window: auto add sdl2 input provider
[INFO   ] Window: virtual keyboard not allowed, single mode, not docked
[DEBUG  ] App: Loading configuration </sdcard/.chatbot.ini>
[DEBUG  ] App: Loading kv </data/user/0/org.vkbot_testing/files/app/chatbot.kv>
[WARNING] Factory: Ignored class "Screen" re-declaration. Current -  module: kivy.uix.screenmanager, cls: None, baseclass: None, filename: None. Ignored -  module: None, cls: None, baseclass: Screen, filename: /data/user/0/org.vkbot_testing/files/app/chatbot.kv.
[WARNING] Factory: Ignored class "TextInput" re-declaration. Current -  module: kivy.uix.textinput, cls: None, baseclass: None, filename: None. Ignored -  module: None, cls: None, baseclass: TextInput, filename: /data/user/0/org.vkbot_testing/files/app/chatbot.kv.
[DEBUG  ] ImageSDL2: Load </data/data/org.vkbot_testing/files/app/data/images/background.jpg>
[INFO   ] GL: NPOT texture support is available
[INFO   ] Text: Provider: sdl2
[DEBUG  ] Atlas: Load </data/user/0/org.vkbot_testing/files/app/lib/python2.7/site-packages/kivy/data/images/defaulttheme.atlas>
[DEBUG  ] Atlas: Need to load 1 images
[DEBUG  ] Atlas: Load </data/user/0/org.vkbot_testing/files/app/lib/python2.7/site-packages/kivy/data/images/defaulttheme-0.png>
[DEBUG  ] ImageSDL2: Load </data/user/0/org.vkbot_testing/files/app/lib/python2.7/site-packages/kivy/data/images/defaulttheme-0.png>
[DEBUG  ] Resource: add </system/fonts> in path list
[DEBUG  ] Resource: add </data/user/0/org.vkbot_testing/files/app/lib/python2.7/site-packages/kivy/data/fonts> in path list
[DEBUG  ] ImageSDL2: Load </data/user/0/org.vkbot_testing/files/app/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-32.png>
[DEBUG  ] ImageSDL2: Load </data/user/0/org.vkbot_testing/files/app/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-32.png>
[DEBUG  ] Cache: register <textinput.label> with limit=None, timeout=60.0
[DEBUG  ] Cache: register <textinput.width> with limit=None, timeout=60.0
[DEBUG  ] Base: Create provider from android
[WARNING] Base: Unknown <android> provider
[INFO   ] Base: Start application main loop
[ERROR  ] Base: Failed to import "android" module. Could not remove android presplash.

Also I can't debug my apk after building (I'm using virtual machine with buildozer and have some problems connecting my device to it)

Maybe I can send you apk file for testing?

@Fogapod
Copy link
Author

Fogapod commented Mar 11, 2017

If so, my_apk_file_here.zip
_20170311_145524
Pressing this button should call notification.notify(title='title', message='message')
(working great on android toolchain, but not on android_new)

@sumitmadhwani
Copy link
Contributor

hi @Fogapod , I tested your app and here are the logs
logs.txt

After doing some research I found that this is a bug in new toolchain.
http://stackoverflow.com/questions/41156449/python-kivy-with-plyer-app-crashes-on-android-camera

Try adding android in requirements section in your buildozer.spec file.
@inclement can help you more over this.

@kuzeyron
Copy link

When I was trying the "android_new" I had to listen through: adb bugreport > bugreport.txt

@Fogapod
Copy link
Author

Fogapod commented Mar 12, 2017

@Malverick, including android to the requirements didn't help.
Kivy logs:

[INFO   ] Logger: Record log in /data/user/0/org.vkbot/files/app/.kivy/logs/kivy_17-03-12_3.txt
[INFO   ] Kivy: v1.9.2.dev0, git-Unknown, 20170310
[INFO   ] Python: v2.7.2 (default, Mar 10 2017, 17:52:09) 
[GCC 4.8]
[INFO   ] Factory: 194 symbols loaded
[DEBUG  ] Cache: register <kv.lang> with limit=None, timeout=None
[DEBUG  ] Cache: register <kv.image> with limit=None, timeout=60
[DEBUG  ] Cache: register <kv.atlas> with limit=None, timeout=None
[INFO   ] Image: Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[DEBUG  ] Cache: register <kv.texture> with limit=1000, timeout=60
[DEBUG  ] Cache: register <kv.shader> with limit=1000, timeout=3600
[INFO   ] OSC: using <thread> for socket
[INFO   ] Window: Provider: sdl2
[INFO   ] GL: Using the "OpenGL ES 2" graphics system
[DEBUG  ] GL: glShaderBinary is not available
[INFO   ] GL: Backend used <gl>
[INFO   ] GL: OpenGL version <OpenGL ES 3.0 [email protected] AU@ (GIT@I741a3d36ca)>
[INFO   ] GL: OpenGL vendor <Qualcomm>
[INFO   ] GL: OpenGL renderer <Adreno (TM) 330>
[INFO   ] GL: OpenGL parsed version: 3, 0
[INFO   ] GL: Texture max size <4096>
[INFO   ] GL: Texture max units <16>
[DEBUG  ] Shader: Fragment compiled successfully
[DEBUG  ] Shader: Vertex compiled successfully
[DEBUG  ] ImageSDL2: Load </data/user/0/org.vkbot/files/app/lib/python2.7/site-packages/kivy/data/glsl/default.png>
[INFO   ] Window: auto add sdl2 input provider
[INFO   ] Window: virtual keyboard not allowed, single mode, not docked
[DEBUG  ] App: Loading configuration </sdcard/.chatbot.ini>
[DEBUG  ] App: Loading kv </data/user/0/org.vkbot/files/app/chatbot.kv>
[WARNING] Factory: Ignored class "Screen" re-declaration. Current -  module: kivy.uix.screenmanager, cls: None, baseclass: None, filename: None. Ignored -  module: None, cls: None, baseclass: Screen, filename: /data/user/0/org.vkbot/files/app/chatbot.kv.
[WARNING] Factory: Ignored class "TextInput" re-declaration. Current -  module: kivy.uix.textinput, cls: None, baseclass: None, filename: None. Ignored -  module: None, cls: None, baseclass: TextInput, filename: /data/user/0/org.vkbot/files/app/chatbot.kv.
[DEBUG  ] ImageSDL2: Load </data/data/org.vkbot/files/app/data/images/background.jpg>
[INFO   ] GL: NPOT texture support is available
[INFO   ] Text: Provider: sdl2
[DEBUG  ] Atlas: Load </data/user/0/org.vkbot/files/app/lib/python2.7/site-packages/kivy/data/images/defaulttheme.atlas>
[DEBUG  ] Atlas: Need to load 1 images
[DEBUG  ] Atlas: Load </data/user/0/org.vkbot/files/app/lib/python2.7/site-packages/kivy/data/images/defaulttheme-0.png>
[DEBUG  ] ImageSDL2: Load </data/user/0/org.vkbot/files/app/lib/python2.7/site-packages/kivy/data/images/defaulttheme-0.png>
[DEBUG  ] Resource: add </system/fonts> in path list
[DEBUG  ] Resource: add </data/user/0/org.vkbot/files/app/lib/python2.7/site-packages/kivy/data/fonts> in path list
[DEBUG  ] ImageSDL2: Load </data/user/0/org.vkbot/files/app/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-32.png>
[DEBUG  ] ImageSDL2: Load </data/user/0/org.vkbot/files/app/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-32.png>
[DEBUG  ] Cache: register <textinput.label> with limit=None, timeout=60.0
[DEBUG  ] Cache: register <textinput.width> with limit=None, timeout=60.0
[DEBUG  ] Base: Create provider from android
[WARNING] Base: Unknown <android> provider
[INFO   ] Base: Start application main loop

@ZingBallyhoo
Copy link

ZingBallyhoo commented Mar 14, 2017

Here is the actual log from the supplied apk, without the logcat filter on: https://gist.github.com/ZingBallyhoo/f3c1bc308bb20a5ff43da94061f39f0c

The most important part of this is: PythonActivity: Accessing org.renpy.android.PythonActivity is deprecated and will be removed in a future version. Please switch to org.kivy.android.PythonActivity.

The issue should be fixed if the android module is properly installed (see https://github.com/kivy/plyer/blob/master/plyer/platforms/android/__init__.py#L8)

@Fogapod can you send me your apk with the android module, so I can see if there is a deeper issue.

@Fogapod
Copy link
Author

Fogapod commented Mar 15, 2017

@ZingBallyhoo
archive.zip

main.py:

from kivy.app import App
from kivy.uix.button import Button

from plyer import notification

import android # no ImportError here

class MyApp(App):
	def build(self):
		return Button(text='notificate', on_press=self.noti)

	def noti(self, *args):
		notification.notify(title='title', message='message')


if __name__ == '__main__':
	MyApp().run()

@ZingBallyhoo
Copy link

@Fogapod Any chance you can rebuild and send me the APK again after you make some changes?

  • Remove plyer from requirements
  • Add git+https://github.com/ZingBallyhoo/plyer.git to requirements

I can see where the issue is, but the exception is silenced by a try: except: pass block

@Fogapod
Copy link
Author

Fogapod commented Mar 15, 2017

Here it is:
archive.zip

Nothing new in kivy logs

@ZingBallyhoo
Copy link

Found the problem, your APK is using an old version of Plyer, before the android_new support.

org.renpy.android.PythonActivity was hardcoded back then, and is deprecated now, hence the error.

What you need to do:

  • Change git+https://github.com/ZingBallyhoo/plyer.git to git+https://github.com/kivy/plyer.git
  • Do a complete clean rebuild:
    • If you are using Buildozer, delete the entire .buildozer folder, this will force a rebuild

Then, it should work

@Fogapod
Copy link
Author

Fogapod commented Mar 15, 2017

But I used master branch of plyer in my first app that I posted here and it didn't work no matter including or excluding android from requirements, I also tried deleting .buildozer folder several times. I'll try to check that again tomorrow.

@ZingBallyhoo
Copy link

@Fogapod I just had a dig around in your original APK's assets, and it is not using plyer from master. Having plyer as a requirement does not use the latest version from github, it uses the latest release on PyPI, which is outdated.

You need to do a clean rebuild to use the latest Plyer (after updating the requirements)

  • To do a clean build:
    • Delete the entire .buildozer folder, this will force a rebuild (Note: this will not cause any issues, or change anything in your code)

This is the file that I found in your APK, which causes the bug:

from os import environ
from jnius import autoclass
ANDROID_VERSION = autoclass('android.os.Build$VERSION')
SDK_INT = ANDROID_VERSION.SDK_INT
if 'PYTHON_SERVICE_ARGUMENT' in environ:
    PythonService = autoclass('org.renpy.android.PythonService')
    activity = PythonService.mService
else:
    PythonActivity = autoclass('org.renpy.android.PythonActivity')
    activity = PythonActivity.mActivity``` 

@Fogapod
Copy link
Author

Fogapod commented Mar 15, 2017

I put plyer directly into my app folder, not using requirements: importing from lib;
Here is this folder, isn't it master?

@ZingBallyhoo
Copy link

@Fogapod Well, the APK you gave us has from plyer import notification, and doesn't even have a libs folder, and yes, the new libs folder does have Plyer from master.

Can you please build the latest version of that app and send it (if it still doesn't work)

@Fogapod
Copy link
Author

Fogapod commented Mar 15, 2017

@ZingBallyhoo ok, that's very weired. I'll build new apk tomorrow. Thanks for your help

@Fogapod
Copy link
Author

Fogapod commented Mar 16, 2017

I created 2 apk's:
android_excluded.zip
android_included.zip

Now both of them are raising NotImplementedError: No usable implementation found!

Edit:
I created third apk including plyer master branch in requirements. It's working fine now. The problem should be in my code. Sorry for wasting your time. Closing issue.

@Fogapod Fogapod closed this as completed Mar 16, 2017
@nancygeorge1997
Copy link

i had the same issue in my speech to text application and i tried all the solutions in the comment but it didnt work , is there a chance anyone can help
here are the logs before and after
errors after solving.txt
errors before solving.txt

@pavankoushal
Copy link

i have created a kivy app in which we can get list of applications in our mobile and we can uninstall apps from my kivy app.it is working good in pc but, when i install it my mobile it is displaying the list of applications but when i press the delete button of respective app, kivy app is crashing.
i had also gone through the logcat . it is showing an error "subprocess.CalledProcessError"

for example i want to delete truecaller app through my kivy app .so when i press the delete button of true caller in kivy app it is showing an error in logact i.e
" subprocess.CalledProcessError: Command 'pm uninstall -k --user 0 com.truecaller ' returned non-zero exit status 255. "
can anybody know what is the error here? or is there any changes i have to do in my buildozer.spec file ?

pls help me to solve this issue

@inclement
Copy link
Member

inclement commented Aug 20, 2020 via email

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

7 participants