jnius.jnius.JavaException:找不到类



我在kivy上制作了一个测试应用程序来调用服务。我有这些文件:

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

服务/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)

结果,我得到了错误:

jnius.jnius.JavaException:找不到类b'org/test/myapp/ServiceMyservice

我试图根据其他用户的建议更改服务参数,但遇到了同样的错误。我应该在服务参数中指定什么来访问服务脚本?

我将包名称和包域更改为

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

我改了这条线。service=autoclass('org.kivy.oscservice.ServiceMyservice')

您的问题已在调试模式下解决。对于释放模式,在‍buildozer -v android release命令,您只需要键入Terminalexport BUILDOZER_ALLOW_KIVY_ORG_DOMAIN=1即可。

相关内容

  • 没有找到相关文章

最新更新