我在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
结果,我得到错误:
jnius.jnius.JavaException: Class not found b'org/test/myapp/ServiceMyservice
我使用这些资源来使用服务:本网站及这个网站。
如果我将package name
和package domain
改为
# (str) Package name
package.name = oscservice
# (str) Package domain (needed for android/ios packaging)
package.domain = org.kivy
和
service = autoclass('org.kivy.oscservice.ServiceMyservice')
问题在调试模式下解决。但是当我想要释放文件时,我在终端上有这个错误:
# ERROR: Trying to release a package that starts with org.kivy
#
# The package.domain org.kivy is reserved for the Kivy official
# applications. Please use your own domain.
#
# If you are a Kivy developer, add an export in your shell
# export BUILDOZER_ALLOW_KIVY_ORG_DOMAIN=1
我应该在service参数中指定什么来访问服务脚本?如果你能告诉我如何使我更接近答案,我将不胜感激。
你需要取消你声明服务的buildozer行注释,否则你要保持它们的注释,怎么可能访问服务
改变#services = Myservice:main.py
services = Myservice:main.py