【问题标题】:problem while deplying kivy app on android device using buildozer (#waiting for application to start)使用 buildozer 在 android 设备上部署 kivy 应用程序时出现问题(#waiting for application to start)
【发布时间】:2021-09-23 12:58:48
【问题描述】:

我正在尝试将 Kivy Selfie 相机应用程序部署到 Android 设备,我在终端上循环收到此消息

#waiting for the application to start

我确保设备已连接并且开发者模式已经激活。那么如何解决这个问题???

【问题讨论】:

    标签: python android kivy virtual-machine buildozer


    【解决方案1】:

    我使用 xcamera 制作了一个 hello world 相机应用程序。

    您可以使用它保存图片,但它只会在应用程序的私有目录范围内。除非您具有root访问权限,否则无法访问。 要将其保存在手机共享内存中,您可以按照此示例进行操作 Click here

    main.py

    from kivy.clock import Clock
    from kivymd.app import MDApp
    from kivy.lang import Builder
    from kivy_garden.xcamera import XCamera
    from android.permissions import request_permissions, Permission
    #from storage import  SharedStorage
    try:
        request_permissions([Permission.INTERNET,
                             Permission.READ_EXTERNAL_STORAGE,
                             Permission.WRITE_EXTERNAL_STORAGE,
                             Permission.CAMERA])
    except Exception as e:
        print("Like it's gonna work after this ! XD")
        print(e)
    KV = """
    #:import XCamera kivy_garden.xcamera.XCamera
    BoxLayout:
        orientation: 'vertical'
        BoxLayout:
            id: camera_layout
            canvas.before:
                PushMatrix
                Rotate:
                    angle: -90
                    origin: self.center
            canvas.after:
                PopMatrix
            XCamera:
                id: camera
    """
    class uiApp(MDApp):
        def shoot(self):
            print("picture taken")
            #SharedStorage().insert(path+local_filename, 'Downloads')
            print("End here")
        def my_callback(self, dt):
            print("Taking picture...")
            self.screen.ids["camera"].shoot()
            print("exit my_callback !")
        def build(self):
            self.screen = Builder.load_string(KV)
            self.screen.ids["camera"].shoot = self.shoot
            self.event = Clock.schedule_once(self.my_callback, 5)
            return self.screen
    uiApp().run()
     
    

    查看要求并确保已安装

    查看本地机器上安装的所有内容 pip list

    buildozer.spec

    [app]
    # (str) Title of your application
    title = Hello_testcamera
    # (str) Package name
    package.name = Testcam
    # (str) Package domain (needed for android/ios packaging)
    package.domain = org.test.cam
    # (str) Source code where the main.py live
    source.dir = .
    # (list) Source files to include (let empty to include all the files)
    source.include_exts = py,png,jpg,kv,atlas,json,xlsx,pdf,crt,pem,cer,ttf,json
    # (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.35
    
    requirements = xcamera,hostpython3==3.7.9,python3==3.7.9,kivy==2.0.0,kivymd==0.104.1,dateutil,urllib3,jmespath,jnius,cython,android,opencv-python,android,pillow,plyer,requests,chardet,idna
    
    orientation = all
    # (list) List of service to declare
    #services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY
    #
    # OSX Specific
    #
    #
    # author = © Copyright Info
    # change the major version of python used by the app
    osx.python_version = 3
    # Kivy version to use
    osx.kivy_version = 1.9.1
    #
    # Android specific
    #
    # (bool) Indicate if the application should be fullscreen or not
    fullscreen = 1
    
    #android.presplash_color = #FFFFFF
    # (list) Permissions
    android.permissions = INTERNET,WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE,CAMERA
    # (int) Target Android API, should be as high as possible.
    android.api = 29
    # (int) Minimum API your APK will support.
    #android.minapi = 27
    # (int) Android SDK version to use
    #android.sdk = 21
    # (str) Android NDK version to use
    #android.ndk = 19c
    # (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
    #android.ndk_api = 21
    android.accept_sdk_license = True
    
    # (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
    android.arch = arm64-v8a
    
    

    【讨论】:

      猜你喜欢
      • 2021-07-08
      • 2020-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 2013-09-30
      • 2011-05-15
      • 1970-01-01
      相关资源
      最近更新 更多