1

I made a test application on kivy to call a service. I have these files:

main.py

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


class TestButton(Button): 
    # When the button is pressed, this function is called
    def run_test_service(self):
        service = autoclass('org.test.myapp.ServiceMyservice')
        mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
        argument = ""
        service.start(mActivity, argument)


class ServiceTestApp(App):
    def build(self):
        return TestButton()


if __name__ == "__main__":
    ServiceTestApp().run()

buildozer.spec

[app]

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

# (str) Package name
package.name = myapp

# (str) Package domain (needed for android/ios packaging)
package.domain = org.test

...

# (list) List of service to declare
#services = Myservice:main.py

service / main.py

from os import environ
from plyer import notification
import time

argument = environ.get('PYTHON_SERVICE_ARGUMENT', '')

while True:
    notification.notify(title="Hello", message="How do you?")
    time.sleep(5)

As a result, I get the error:

jnius.jnius.JavaException: Class not found b'org/test/myapp/ServiceMyservice

I tried to change the service argument following the advice of other users, but got the same error. What should I specify in the service argument to access the service script?

Karl
  • 126
  • 4

1 Answers1

1

I changed package name and package domain to

# (str) Package name
package.name = oscservice

# (str) Package domain (needed for android/ios packaging)
package.domain = org.kivy

and I changed this line.service=autoclass('org.kivy.oscservice.ServiceMyservice')

Your problem is solved in debug mode. For the release mode, before the ‍buildozer -v android release command, you just need to type in Terminal export BUILDOZER_ALLOW_KIVY_ORG_DOMAIN=1.