-1

I want to create a fbchatbot and use it alongside with kivy . To do this , i need to import fbchat-asyncio modules which are required for the chatbot to run.

I have tried included the fbchat-asyncio modules in requirement line in the Buildozer.spec file.

I also tried to include all the folder package of fbchat-asyncio and dump inside the .Buildozer folder

The program work perfectly fine on the pc , but when i ran it on my phone with the apk file . It crash within one second . I suspect its because it cannot recognize the fbchat-asyncio


from kivy.uix.widget import Widget
#-*- coding: utf-8 -*-
from kivy.app import App
from fbchat import Client, ThreadType
import asyncio
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.popup import Popup
from kivy.uix.textinput import TextInput

#
from kivy.uix.gridlayout import GridLayout
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
import time
time.sleep(2)
#create a class to place all widget
class OurGrid(GridLayout):

    def __init__(self,**kwargs): #kwarg mean can handle more parameter
        super(OurGrid,self).__init__(**kwargs)
        self.cols = 1 # can set the layout




        self.inside = GridLayout()
        self.inside.cols = 2

        self.inside.add_widget(Label(text="User Name : ",italic=True,bold=True))
        self.name = TextInput(multiline="false")
        self.inside.add_widget(self.name)

        # self.inside.add_widget(Label(text="Last Name : ",italic=True,bold=True))
        # self.lastName = TextInput(multiline="false")
        # self.inside.add_widget(self.lastName)

        self.inside.add_widget(Label(text="Password : ",italic=True,bold=True))
        self.password = TextInput(multiline="false")
        self.inside.add_widget(self.password)
        self.add_widget(self.inside)
        #label -----
        self.labelShow = Label(text=self.name.text)
        self.add_widget(self.labelShow)
        #add the label
        self.btnLogin = Button(text="Login",font_size=30)
        self.add_widget(self.btnLogin)
        self.btnLogin.bind(on_press=self.press)


        # btn1 = Button(text="Ok", italic=True)
        # btn2 = Button(text="Exit", italic=True)
        # self.add_widget(btn1)
        # self.add_widget(btn2)


        #btnLogin.bind(on_press=lambda *a: messageShow(self.email.text))
    def press(self,instance):

        name = self.name.text
        password = self.password.text
        if name !="" and password != "":
            self.labelShow.text = "Login......"
            class EchoBot(Client):

                async def on_message(self, mid=None, author_id=None, message_object=None, thread_id=None,
                                     thread_type=ThreadType.USER, at=None, metadata=None, msg=None):
                    await self.mark_as_delivered(thread_id, message_object.uid)
                    await self.mark_as_read(thread_id)


                    # If you're not the author, echo
                    if author_id != self.uid:
                        await self.send(message_object, thread_id=thread_id, thread_type=thread_type)
            loop = asyncio.get_event_loop()

            async def start():
                client = EchoBot(loop=loop)
                #print("Logging in...")

                await client.start(name, password)
                client.listen()
            #
            loop.run_until_complete(start())
            loop.run_forever()
        else:
            self.labelShow.text = "Fail Login Pls Input all information"


        #
        self.labelShow.text = self.email.text


    #name and email must be same in kivy file left


class MyApp(App): # get all method from the import app from the kivy
    def build(self):
        #build is what we gonna put inside the window
        #we put a label inside a window


        return OurGrid() # GET ALL THE INHERIT FROM MY GRID CLASS
        #return Label(text="fafwfwa")


if __name__ =="__main__":
    MyApp().run()#run the class so we get a label











Does anyone know how can i include others package like fbchat-asyncio to the kivy apk in the phone?

Jon Kim
  • 97
  • 1
  • 11

1 Answers1

0

Think you run in the same error as asked in When building an apk for my samsung using buildozer an error occurs

So I think when you read the logs you get the following error:

ModuleNotFoundError: No module named 'asyncio'

Possible ways to solve:

  1. Check if module is pure python so it's possible to include
  2. Check if you can create a recipe so it will be deployed
  3. Use a module which is already available as recipe
Thomas Strub
  • 1,275
  • 7
  • 20