So i have been trying to create a .apk file of a .py file with the help of buildozer and kivymd. The problem I am facing is the apk is being successfully created but whenever I open the app it crashes after the loading screen.
I am new to both python and kivymd as well as buildozer so I am not able to find the issue. A little help will be really appreciated.
Below is the code!
import pygame
import requests
from kivymd.app import MDApp
class Mainapp(MDApp):
def build(self):
WIDTH = 550
background_colour = (251,247,245)
og_grid_element_colour = (52, 31, 151)
buffer = 5
response = requests.get("https://sugoku.herokuapp.com/board?difficulty=medium")
grid = response.json()['board']
grid_original = [[grid[x][y] for y in range(len(grid[0]))] for x in range(len(grid))]
def insert(win, postion):
i,j = postion[1], postion[0]
myfont = pygame.font.SysFont("Times New Roman ", 35)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
if event.type == pygame.KEYDOWN:
if(grid_original[i-1][j-1] !=0):
return
if(event.key == 48):
grid[i-1][j-1] = event.key - 48
pygame.draw.rect(win, background_colour, (postion[0]*50 + buffer, postion[1]*50 + buffer, 50 - 2*buffer, 50 - 2*buffer))
pygame.display.update()
if(0 , event.key - 48 < 10 ):
pygame.draw.rect(win, background_colour, (postion[0]*50 + buffer, postion[1]*50 + buffer, 50 - 2*buffer, 50 - 2*buffer))
value = myfont.render(str(event.key-48), True, (0,0,0))
win.blit(value, (postion[0]*50+15, postion[1]*50))
grid[i-1][j-1] = event.key - 48
pygame.display.update()
return
def main():
pygame.init()
win = pygame.display.set_mode((WIDTH, WIDTH))
pygame.display.set_caption("Sudoku")
win.fill(background_colour)
myfont = pygame.font.SysFont("Times New Roman ", 35)
for i in range(0,10):
if(i%3 == 0):
pygame.draw.line(win, (0,0,0), (50 + 50*i, 50), (50 + 50*i, 500), 4)
pygame.draw.line(win, (0,0,0), (50, 50 + 50*i), (500, 50 + 50*i), 4)
pygame.draw.line(win, (0,0,0), (50 + 50*i, 50), (50 + 50*i, 500), 2)
pygame.draw.line(win, (0,0,0), (50, 50 + 50*i), (500, 50 + 50*i), 2)
pygame.display.update()
for i in range(0, len(grid[0])):
for j in range(0, len(grid[0])):
if(0<grid[i][j]<10):
value = myfont.render(str(grid[i][j]), True, og_grid_element_colour)
win.blit(value, ((j+1)*50 + 15, (i+1)*50 + 6))
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONUP and event.button == 1:
pos = pygame.mouse.get_pos()
insert(win, (pos[0]//50 , pos[1]//50))
if event.type == pygame.QUIT:
pygame.quit()
return
main()
if __name__ == '__main__':
Mainapp().run()