【问题标题】:Plyer "makecall" crashes my Kivy/Buildozer application (NotImplementedError)Plyer“makecall”使我的 Kivy/Buildozer 应用程序崩溃 (NotImplementedError)
【发布时间】:2020-12-02 10:14:40
【问题描述】:

我正在为 Android/iOS 制作 Python3/Kivy 应用程序。它使用beautifulsoup4 从网站上抓取信息(通过一种解决方法来绕过htmlparser 的错误)并使用Kivy 在屏幕上显示它们。我还添加了 4 个按钮,3 个用于社交媒体,一个用于为手机模块提供电话号码。

对于这一部分,我使用 plyer 定义 phonecall() 和 call.makecall() 方法。 这根本不起作用,当我尝试添加该按钮绑定时,我的应用程序在 GNU/Linux 或 Android 上崩溃。你能帮帮我吗?

在我的 main.py 中导入了什么:

import sys
import kivy
kivy.require('1.9.1')
import os
import time
import requests
import webbrowser
from kivy.app import App
from kivy.config import Config  
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
import plyer
from plyer import call
import bs4
import jnius
from jnius import autoclass

我在 main.py 上的主类:

class ConceptruelleApp(App):

def build(self):
    """
    Scrape ConcepTruelle's website agenda and put it on screen
    4 buttons give access to website, social medias and phone number
    """
    def phonecall(self):
        """
        Make a Phone Call on Android with Plyer
        """
        call.makecall(tel=tel)
     
    def website(self):
        """
        Open ConcepTruelle's website
        """
        webbrowser.open("http://conceptruelle.fr/")

    def facebook(self):
        """
        Open ConcepTruelle's Facebook page
        """
        webbrowser.open("https://www.facebook.com/ConcepTruelle")

    def instagram(self):
        """
        Open ConcepTruelle's Instagram page
        """
        webbrowser.open("https://www.instagram.com/conceptruelle")
    
    # Main application : definition of title, labels and buttons put on a Float Layout
    fl = FloatLayout()
    lbl0 = MyTitle(text = "  [size=90][color=000000]L\'[/color][color=dd9514][i]Agenda[/i][/color] [color=000000][b]ConcepTruelle[/b][/size][/color]", markup=True, size_hint =(1, .1), pos_hint ={'center_x':.5, 'center_y':.97})
    lbl1 = MyLabel1(text = event_title_1 + "\n" + agenda1, size_hint =(1, .5), pos_hint ={'center_x':.5, 'center_y':1.03})
    lbl2 = MyLabel2(text = event_title_2 + "\n" + agenda2, size_hint =(1, .5), pos_hint ={'center_x':.5, 'center_y':.86})
    lbl3 = MyLabel1(text = event_title_3 + "\n" + agenda3, size_hint =(1, .5), pos_hint ={'center_x':.5, 'center_y':.69})
    lbl4 = MyLabel2(text = event_title_4 + "\n" + agenda4, size_hint =(1, .5), pos_hint ={'center_x':.5, 'center_y':.52})
    lbl5 = MyLabel1(text = event_title_5 + "\n" + agenda5, size_hint =(1, .5), pos_hint ={'center_x':.5, 'center_y':.35})
    fl.add_widget(lbl0)
    fl.add_widget(lbl1)
    fl.add_widget(lbl2)
    fl.add_widget(lbl3)
    fl.add_widget(lbl4)
    fl.add_widget(lbl5)
    btn1 = Button(text = "Appel", size_hint =(.25, .1), pos_hint ={'center_x':.125, 'center_y':.05})
    tel = 9999999999
    btn1.bind(on_press=phonecall(tel))
    btn2 = Button(text = "Site Web", size_hint =(.25, .1), pos_hint ={'center_x':.375, 'center_y':.05})
    btn2.bind(on_press=website)
    btn3 = Button(text = "Facebook", size_hint =(.25, .1), pos_hint ={'center_x':.625, 'center_y':.05})
    btn3.bind(on_press=facebook)
    btn4 = Button(text = "Instagram", size_hint =(.25, .1), pos_hint ={'center_x':.875, 'center_y':.05})
    btn4.bind(on_press=instagram)
    fl.add_widget(btn1)
    fl.add_widget(btn2)
    fl.add_widget(btn3)
    fl.add_widget(btn4)
    return fl

在我的 buildozer.spec 上:

requirements = python3,kivy==master,plyer,requests,beautifulsoup4,html5lib,urllib3,chardet,idna,android,pyjnius

android.permissions = INTERNET,WRITE_EXTERNAL_STORAGE,CALL_PHONE,CALL_PRIVILEGED,BLUETOOTH

我的日志文件:

12-02 10:36:13.882  4613  4708 I python  :  Traceback (most recent call last):

12-02 10:36:13.883  4613  4708 I python  :    File "/home/guillaume/Documents/Python/ConcepTruelle_3/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/conceptruelle/plyer/utils.py", line 96, in _ensure_obj

12-02 10:36:13.886  4613  4708 I python  :  ModuleNotFoundError: No module named 'plyer.platforms'

12-02 10:36:13.891  4613  4708 I python  :  Traceback (most recent call last):

12-02 10:36:13.899  4613  4708 I python  :    File "/home/guillaume/Documents/Python/ConcepTruelle_3/.buildozer/android/app/main.py", line 194, in <module>

12-02 10:36:13.907  4613  4708 I python  :    File "/home/guillaume/Documents/Python/ConcepTruelle_3/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/conceptruelle/kivy/app.py", line 829, in run

12-02 10:36:13.912  4613  4708 I python  :    File "/home/guillaume/Documents/Python/ConcepTruelle_3/.buildozer/android/app/main.py", line 133, in build

12-02 10:36:13.914  4613  4708 I python  :    File "/home/guillaume/Documents/Python/ConcepTruelle_3/.buildozer/android/app/main.py", line 97, in phonecall

12-02 10:36:13.916  4613  4708 I python  :    File "/home/guillaume/Documents/Python/ConcepTruelle_3/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/conceptruelle/plyer/facades/call.py", line 45, in makecall

12-02 10:36:13.918  4613  4708 I python  :    File "/home/guillaume/Documents/Python/ConcepTruelle_3/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/conceptruelle/plyer/facades/call.py", line 56, in _makecall

12-02 10:36:13.920  4613  4708 I python  :  NotImplementedError

12-02 10:36:13.921  4613  4708 I python  : Python for android ended.

12-02 10:36:14.190   848  5842 I ActivityManager: Process org.conceptruelle.conceptruelle (pid 4613) has died: fore TOP 

12-02 10:36:14.191   848  2780 I WindowManager: WIN DEATH: Window{9843b0a u0 org.conceptruelle.conceptruelle/org.kivy.android.PythonActivity}

【问题讨论】:

    标签: python android kivy call


    【解决方案1】:

    请求清单的权限是不够的。我用这些线解决了它:

    import android
    from android.permissions import request_permissions, Permission
    request_permissions([Permission.CALL_PHONE])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-10
      • 2022-10-21
      • 2021-09-28
      • 2017-02-14
      • 2020-11-29
      • 2020-10-25
      • 1970-01-01
      相关资源
      最近更新 更多