kivy / plyer

Plyer is a platform-independent Python wrapper for platform-dependent APIs
https://plyer.readthedocs.io
MIT License
1.61k stars 426 forks source link

Notification and service #494

Closed lelapin123 closed 5 years ago

lelapin123 commented 5 years ago

Hello,

I can use Plyer to create a notification from the main python file, but i cant do the same thing from /service/main.py with ANDROID with the service launched (i dont have my files with me to paste a code sample now). It works with linux. It says something like "no usable implementation" with adb. Is this a known problem ?

(I use buildozer to create the app)

KeyWeeUsr commented 5 years ago

@lelapin123 I'm not sure since I haven't tried with an Android service yet, however make sure you have android included in your requirements because most likely it fails due to an ImportError from https://github.com/kivy/plyer/blob/72666d5478b3d8854285e84c51d35f6cdcd3aa8c/plyer/platforms/android/notification.py#L5

If that's not the case, please provide the full Traceback log from ADB with the lines related to Python (or your application).

lelapin123 commented 5 years ago

I have to add android as requirement in the buildozer file, otherwise the app doesnt send notifications even with the main py file ( it returns a kind of not found error). I ll paste the log in about 10 days when i can again (i am just warning you, may be it is long delay on this forum). There is nothing to add in buildozer.spec when you use a service ? (i declared my service in it, but i am not sure if its name matters and what the declaration in this file does)

lelapin123 commented 5 years ago

So here is finally my code:

for main.py

from kivy.app import App
from kivy.lang import Builder
from oscpy.server import OSCThreadServer
from kivy.clock import Clock
from kivy.utils import platform

from plyer import notification
from plyer.utils import platform
from plyer.compat import PY2

activityport = 3691
serviceport = 3690

osc = OSCThreadServer()

sock = osc.listen(address='127.0.0.1', port=activityport, default=True)
@osc.address(b'/plonk')

def callback(values):
    print("got values: {}".format(values))

kv = '''
Button:
    text: 'push me!'
    on_press: app.ping()
'''

class ServiceApp(App):
    def build(self):

        if platform == 'android':
            from android import AndroidService
            service = AndroidService('pgc', 'running')

            service.start('Checking')
            self.service = service

        osc.send_message(b'/plonk', ['iii'], '127.0.0.1', activityport)

        return Builder.load_string(kv)

    def ping(self):

        osc.send_message(b'/plonk', ['iii'], '127.0.0.1', serviceport)

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

For service/main.py

from time import sleep
from oscpy.server import OSCThreadServer

import kivy
from kivy.app import App

import plyer
from plyer import notification
from plyer.utils import platform
from plyer.compat import PY2
from kivy.lib import osc

activityport = 3691
serviceport = 3690
osc = OSCThreadServer()
sock = osc.listen(address='127.0.0.1', port=serviceport, default=True)
@osc.address(b'/plonk')

def callback(values):
    print("got values: {}".format(values))
    answer_message()

def answer_message():   

    if platform == 'android':
        #from android import AndroidService
    print 'huhuhu'

    notification.notify('test tiltle','scanning started')
    osc.send_message(b'/plonk', ['aaa'], '127.0.0.1', activityport)

if __name__ == '__main__':

    sleep(1000)
    osc.stop()

I get this with: adb shell logcat python:D *:S


01-15 18:09:40.389 16451 16517 I python  :  Traceback (most recent call last):
01-15 18:09:40.390 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/plyer/utils.py", line 96, in _ensure_obj
01-15 18:09:40.391 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/plyer/platforms/android/__init__.py", line 8, in <module>
01-15 18:09:40.391 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/android/__init__.py", line 8, in <module>
01-15 18:09:40.392 16451 16517 I python  :    File "android/_android.pyx", line 178, in init android._android (android/_android.c:6398)
01-15 18:09:40.394 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/jnius/reflect.py", line 159, in autoclass
01-15 18:09:40.395 16451 16517 I python  :    File "jnius/jnius_export_func.pxi", line 26, in jnius.jnius.find_javaclass (jnius/jnius.c:15056)
01-15 18:09:40.396 16451 16517 I python  :  JavaException: Class not found 'org/kivy/android/PythonActivity'
01-15 18:09:40.398 16451 16517 I python  :  Exception in thread Thread-1:
01-15 18:09:40.398 16451 16517 I python  :  Traceback (most recent call last):
01-15 18:09:40.399 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/build/other_builds/python2-openssl/armeabi-v7a/python2/python-install/lib/python2.7/threading.py", line 552, in __bootstrap_inner
01-15 18:09:40.400 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/build/other_builds/python2-openssl/armeabi-v7a/python2/python-install/lib/python2.7/threading.py", line 505, in run
01-15 18:09:40.400 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/oscpy/server.py", line 269, in _listen
01-15 18:09:40.401 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/app/service/main.py", line 28, in callback
01-15 18:09:40.401 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/app/service/main.py", line 36, in answer_message
01-15 18:09:40.401 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/plyer/facades/notification.py", line 84, in notify
01-15 18:09:40.402 16451 16517 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/plyer/facades/notification.py", line 90, in _notify
01-15 18:09:40.402 16451 16517 I python  :  NotImplementedError: No usable implementation found!
01-15 18:09:40.403 16451 16517 I python  :  

with

    from android import AndroidService
    from android.config import JAVA_NAMESPACE 
    print 'huhuhu'

in service/main.py

01-15 18:12:35.870 17351 17409 I python  :  Exception in thread Thread-1:
01-15 18:12:35.871 17351 17409 I python  :  Traceback (most recent call last):
01-15 18:12:35.871 17351 17409 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/build/other_builds/python2-openssl/armeabi-v7a/python2/python-install/lib/python2.7/threading.py", line 552, in __bootstrap_inner
01-15 18:12:35.871 17351 17409 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/build/other_builds/python2-openssl/armeabi-v7a/python2/python-install/lib/python2.7/threading.py", line 505, in run
01-15 18:12:35.871 17351 17409 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/oscpy/server.py", line 269, in _listen
01-15 18:12:35.872 17351 17409 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/app/service/main.py", line 28, in callback
01-15 18:12:35.872 17351 17409 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/app/service/main.py", line 33, in answer_message
01-15 18:12:35.872 17351 17409 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/android/__init__.py", line 8, in <module>
01-15 18:12:35.873 17351 17409 I python  :    File "android/_android.pyx", line 178, in init android._android (android/_android.c:6398)
01-15 18:12:35.873 17351 17409 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/jnius/reflect.py", line 159, in autoclass
01-15 18:12:35.873 17351 17409 I python  :    File "jnius/jnius_export_func.pxi", line 26, in jnius.jnius.find_javaclass (jnius/jnius.c:15056)
01-15 18:12:35.873 17351 17409 I python  :  JavaException: Class not found 'org/kivy/android/PythonActivity'
01-15 18:12:35.874 17351 17409 I python  :  

If i try to import jnius, on linux i get this with service/main.py

Traceback (most recent call last):
   File "./main.py", line 15, in <module>
     import jnius
   File "/usr/local/lib/python2.7/dist-packages/jnius/__init__.py", line 13, in <module>
     from .reflect import *  # noqa
   File "/usr/local/lib/python2.7/dist-packages/jnius/reflect.py", line 15, in <module>
     class Class(with_metaclass(MetaJavaClass, JavaClass)):
   File "/usr/local/lib/python2.7/dist-packages/six.py", line 827, in __new__
     return meta(name, bases, d)
   File "jnius_export_class.pxi", line 111, in jnius.MetaJavaClass.__new__ (jnius/jnius.c:17034)
   File "jnius_export_class.pxi", line 161, in jnius.MetaJavaClass.resolve_class (jnius/jnius.c:17865)
   File "jnius_env.pxi", line 11, in jnius.get_jnienv (jnius/jnius.c:3362)
   File "jnius_jvm_dlopen.pxi", line 90, in jnius.get_platform_jnienv (jnius/jnius.c:3296)
   File "jnius_jvm_dlopen.pxi", line 45, in jnius.create_jnienv (jnius/jnius.c:2727)
   File "/usr/lib/python2.7/UserDict.py", line 40, in __getitem__
     raise KeyError(key)
 KeyError: 'JAVA_HOME'

my buildozer.spec file is:


[app]

# (str) Title of your application
title = My coolApplication

# (str) Package name
package.name = mytestapp

# (str) Package domain (needed for android/ios packaging)
package.domain = blablabla.com

# (str) Source code where the main.py live
source.dir = /home/miaw/work/app_steam/1/

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas

# (list) List of inclusions using pattern matching
#source.include_patterns = assets/*,images/*.png

# (list) Source files to exclude (let empty to not exclude anything)
#source.exclude_exts = spec

# (list) List of directory to exclude (let empty to not exclude anything)
#source.exclude_dirs = tests, bin

# (list) List of exclusions using pattern matching
#source.exclude_patterns = license,images/*/*.jpg

# (str) Application versioning (method 1)
version = 0.1

# (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"]
# version.filename = %(source.dir)s/main.py

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = kivy, android, openssl, pyopenssl, request, pathlib, datetime, plyer, urllib3, oscpy, pyjnius

# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy

# (list) Garden requirements
#garden_requirements =

# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png

# (str) Supported orientation (one of landscape, portrait or all)
orientation = portrait

# (list) List of service to declare
##services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY
services = pgc:./service/main.py 

#
# OSX Specific
#

#
# author = © Copyright Info

# change the major version of python used by the app
osx.python_version = 2

# Kivy version to use
osx.kivy_version = 1.10.1

#
# Android specific
#

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 0

# (string) Presplash background color (for new android toolchain)
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
# olive, purple, silver, teal.
#android.presplash_color = #FFFFFF

# (list) Permissions
android.permissions = INTERNET, WRITE_EXTERNAL_STORAGE, ACCESS_NETWORK_STATE

# (int) Android API to use
#android.api = 19

# (int) Minimum API required
#android.minapi = 9

# (int) Android SDK version to use
#android.sdk = 20

# (str) Android NDK version to use
#android.ndk = 9c

# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True

# (str) Android NDK directory (if empty, it will be automatically downloaded.)
#android.ndk_path =

# (str) Android SDK directory (if empty, it will be automatically downloaded.)
#android.sdk_path =

# (str) ANT directory (if empty, it will be automatically downloaded.)
#android.ant_path =

# (bool) If True, then skip trying to update the Android sdk
# This can be useful to avoid excess Internet downloads or save time
# when an update is due and you just want to test/build your package
# android.skip_update = False

# (str) Android entry point, default is ok for Kivy-based app
#android.entrypoint = org.renpy.android.PythonActivity

# (list) Pattern to whitelist for the whole project
#android.whitelist =

# (str) Path to a custom whitelist file
#android.whitelist_src =

# (str) Path to a custom blacklist file
#android.blacklist_src =

# (list) List of Java .jar files to add to the libs so that pyjnius can access
# their classes. Don't add jars that you do not need, since extra jars can slow
# down the build process. Allows wildcards matching, for example:
# OUYA-ODK/libs/*.jar
#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar

# (list) List of Java files to add to the android project (can be java or a
# directory containing the files)
#android.add_src =

# (list) Android AAR archives to add (currently works only with sdl2_gradle
# bootstrap)
#android.add_aars =

# (list) Gradle dependencies to add (currently works only with sdl2_gradle
# bootstrap)
#android.gradle_dependencies =

# (list) Java classes to add as activities to the manifest.
#android.add_activites = com.example.ExampleActivity

# (str) python-for-android branch to use, defaults to stable
#p4a.branch = stable

# (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled
#android.ouya.category = GAME

# (str) Filename of OUYA Console icon. It must be a 732x412 png image.
#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png

# (str) XML file to include as an intent filters in <activity> tag
#android.manifest.intent_filters =

# (str) launchMode to set for the main activity
#android.manifest.launch_mode = standard

# (list) Android additional libraries to copy into libs/armeabi
android.add_libs_armeabi = libs/android/*.so
android.add_libs_armeabi_v7a = libs/android-v7/*.so
#android.add_libs_x86 = libs/android-x86/*.so
#android.add_libs_mips = libs/android-mips/*.so

# (bool) Indicate whether the screen should stay on
# Don't forget to add the WAKE_LOCK permission if you set this to True
#android.wakelock = False

# (list) Android application meta-data to set (key=value format)
#android.meta_data =

# (list) Android library project to add (will be added in the
# project.properties automatically.)
#android.library_references =

# (str) Android logcat filters to use
#android.logcat_filters = *:S python:D

# (bool) Copy library instead of making a libpymodules.so
#android.copy_libs = 1

# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86
android.arch = armeabi-v7a

#
# Python for android (p4a) specific
#

# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
p4a.source_dir = /home/miaw/work/bdo/python-for-android/

#p4a.source_dir = /home/miaw/work/app_steam/python-for-android/

# (str) The directory in which python-for-android should look for your own build recipes (if any)
#p4a.local_recipes =

# (str) Filename to the hook for p4a
#p4a.hook =

# (str) Bootstrap to use for android builds
# p4a.bootstrap = sdl2

# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
#p4a.port =

#
# iOS specific
#

# (str) Path to a custom kivy-ios folder
#ios.kivy_ios_dir = ../kivy-ios

# (str) Name of the certificate to use for signing the debug version
# Get a list of available identities: buildozer ios list_identities
#ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"

# (str) Name of the certificate to use for signing the release version
#ios.codesign.release = %(ios.codesign.debug)s

[buildozer]

# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 1

# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
warn_on_root = 1

# (str) Path to build artifact storage, absolute or relative to spec file
build_dir = ./.buildozer

# (str) Path to build output (i.e. .apk, .ipa) storage
bin_dir = ./bin

#    -----------------------------------------------------------------------------
#    List as sections
#
#    You can define all the "list" as [section:key].
#    Each line will be considered as a option to the list.
#    Let's take [app] / source.exclude_patterns.
#    Instead of doing:
#
#[app]
#source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
#
#    This can be translated into:
#
#[app:source.exclude_patterns]
#license
#data/audio/*.wav
#data/images/original/*
#

#    -----------------------------------------------------------------------------
#    Profiles
#
#    You can extend section / key with a profile
#    For example, you want to deploy a demo version of your application without
#    HD content. You could first change the title to add "(demo)" in the name
#    and extend the excluded directories to remove the HD content.
#
#[app@demo]
#title = My Application (demo)
#
#[app:source.exclude_patterns@demo]
#images/hd/*
#
#    Then, invoke the command line with the "demo" profile:
#
#buildozer --profile demo android debug
lelapin123 commented 5 years ago

Ok so a little update. It seems that my problem is quite similar to this one: https://github.com/kivy/plyer/issues/467

So i have to have an android module from p4a.

I don't remember what i did to have p4a, since when i comment the line: p4a.source_dir = /home/miaw/work/bdo/python-for-android/ in order to make buildozer download p4a, it doesn't work. (connection problem ?)

error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
# Command failed: git clone -b stable --single-branch https://github.com/kivy/python-for-android.git python-for-android-new-toolchain
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 

But i have no idea why there is no android module from my p4a.

What am i supposed to do to get android module from p4a

KeyWeeUsr commented 5 years ago

Yes, it seems like a connection problem (or curl settings are wrong?). Anyway, you can just download an ordinary zip archive from github:

https://github.com/kivy/python-for-android/archive/stable.zip'

and then point the buildozer to the correct location. To include android module in your project you need to add it to the requirements.

lelapin123 commented 5 years ago

so i download this:

https://github.com/kivy/python-for-android/archive/stable.zip

unzip it in /home/miaw/work/app_steam/python-for-android-stable

correct in buildozer.spec

p4a.source_dir = /home/miaw/work/app_steam/python-for-android-stable

also in buildozer.spec:

requirements = kivy, android, openssl, pyopenssl, request, pathlib, datetime, plyer, urllib3, oscpy, pyjnius, jnius

which is probably much more than needed (note the presence of "android")

If my service/main.py file contains:

    import android

then i get this error

01-18 18:08:01.550 21631 21699 I python  :  Traceback (most recent call last):
01-18 18:08:01.550 21631 21699 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/build/other_builds/python2-openssl/armeabi-v7a/python2/python-install/lib/python2.7/threading.py", line 552, in __bootstrap_inner
01-18 18:08:01.550 21631 21699 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/jnius/__init__.py", line 54, in jnius_thread_hook
01-18 18:08:01.550 21631 21699 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/build/other_builds/python2-openssl/armeabi-v7a/python2/python-install/lib/python2.7/threading.py", line 505, in run
01-18 18:08:01.551 21631 21699 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/oscpy/server.py", line 269, in _listen
01-18 18:08:01.551 21631 21699 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/app/service/main.py", line 37, in callback
01-18 18:08:01.551 21631 21699 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/app/service/main.py", line 42, in answer_message
01-18 18:08:01.551 21631 21699 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/android/__init__.py", line 8, in <module>
01-18 18:08:01.551 21631 21699 I python  :    File "android/_android.pyx", line 178, in init android._android (android/_android.c:6398)
01-18 18:08:01.551 21631 21699 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/jnius/reflect.py", line 159, in autoclass
01-18 18:08:01.551 21631 21699 I python  :    File "jnius/jnius_export_func.pxi", line 26, in jnius.jnius.find_javaclass (jnius/jnius.c:15056)
01-18 18:08:01.552 21631 21699 I python  :  JavaException: Class not found 'org/kivy/android/PythonActivity'
01-18 18:08:01.552 21631 21699 I python  :  

If i comment "import android"

 if platform != 'android':
    #import android 

Then i get this error:

01-18 18:16:31.115 24311 24330 I python  : huhuhu
01-18 18:16:31.147 24311 24330 I python  :  Traceback (most recent call last):
01-18 18:16:31.148 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/plyer/utils.py", line 96, in _ensure_obj
01-18 18:16:31.148 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/plyer/platforms/android/__init__.py", line 8, in <module>
01-18 18:16:31.149 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/android/__init__.py", line 8, in <module>
01-18 18:16:31.149 24311 24330 I python  :    File "android/_android.pyx", line 178, in init android._android (android/_android.c:6398)
01-18 18:16:31.150 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/jnius/reflect.py", line 159, in autoclass
01-18 18:16:31.151 24311 24330 I python  :    File "jnius/jnius_export_func.pxi", line 26, in jnius.jnius.find_javaclass (jnius/jnius.c:15056)
01-18 18:16:31.152 24311 24330 I python  :  JavaException: Class not found 'org/kivy/android/PythonActivity'
01-18 18:16:31.153 24311 24330 I python  :  Exception in thread Thread-1:
01-18 18:16:31.153 24311 24330 I python  :  Traceback (most recent call last):
01-18 18:16:31.153 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/build/other_builds/python2-openssl/armeabi-v7a/python2/python-install/lib/python2.7/threading.py", line 552, in __bootstrap_inner
01-18 18:16:31.154 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/jnius/__init__.py", line 54, in jnius_thread_hook
01-18 18:16:31.154 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/build/other_builds/python2-openssl/armeabi-v7a/python2/python-install/lib/python2.7/threading.py", line 505, in run
01-18 18:16:31.154 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/oscpy/server.py", line 269, in _listen
01-18 18:16:31.154 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/app/service/main.py", line 37, in callback
01-18 18:16:31.155 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/app/service/main.py", line 45, in answer_message
01-18 18:16:31.155 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/plyer/facades/notification.py", line 84, in notify
01-18 18:16:31.155 24311 24330 I python  :    File "/home/miaw/work/app_steam/1/.buildozer/android/platform/build/dists/mytestapp/private/lib/python2.7/site-packages/plyer/facades/notification.py", line 90, in _notify
01-18 18:16:31.156 24311 24330 I python  :  NotImplementedError: No usable implementation found!
01-18 18:16:31.156 24311 24330 I python  :  

So my guess here is that it is better to include "import android" in the source code. BUT that i have another error when i do that:

JavaException: Class not found 'org/kivy/android/PythonActivity' 

First, am i right ? Second what is the problem with this error ?

JavaException: Class not found 'org/kivy/android/PythonActivity' 

What to do to fix that ?

lelapin123 commented 5 years ago

A question: does it create a problem of PATH to call something related to "'org/kivy/android/PythonActivity'" from /service/main.py instead of main.py ?

lelapin123 commented 5 years ago

So or i get an error "NotImplementedError: No usable implementation found!" if i just i add:

notification.notify('test tiltle','scanning started')

or i get an error

JavaException: Class not found 'org/kivy/android/PythonActivity

if i add: import android

(even without the line for the notification) Same thing if i add:

activity = autoclass('org.kivy.android.PythonActivity')

Can i make a temporary fix if edit some files, life manifest files ?

I don't think i can fix the problem myself.

(btw did someone try my code ? were you able to make it work ?)

KeyWeeUsr commented 5 years ago

I believe the error is only about kivy in the org/kivy/android/PythonActivity and it appears to me that you for some reason have the old path org/renpy/android/PythonActivity present. Perhaps you have some old Python build cached in your .buildozer folder.

However I tried your code and I wasn't able to start the service with the android.AndroidService as it failed on the AndroidService.start method with this error:

Unable to start service Intent { cmp=org.kivy.package/org.kivy.android.PythonService (has extras) } U=0: not found

However none of those is related to Plyer and the notifications alone are working just fine. I'm closing this issue. Feel free to update buildozer, clean .buildozer folder, so that you don't have cached stuff and build the app again. If it doesn't work, please visit https://chat.kivy.org

Also, it makes no sense to try to access Android classes and classes used on the platform provided by python-for-android because there will never be such a class available and/or correctly compiled due to dependency on Android SDK and autoclass() will always fail.