Closed walfredcutaran closed 1 year ago
This should probably be a support request on Discord or GoogleGroups.
Does the app use Pyjnius?
Pyjnius as a requirement in the spec file, no. But when i see buildozer debug is ran, im seeing some pyjnius being extracted if i am not mistaken...
Update: the application works on android 9 and 10 only, weird on later devices it gives that error
What's weirder is it works before last month on my android 12 device... Now it doesn't
The "weird" you describe is normal for memory issues in any program, null pointer is also an example of a memory issue. It looks like the code in your app contains a memory management issue, the question is why?
Perhaps I was not clear. Does the app Python code contain Pyjnius autoclass statements?
here is my main.py file if you like to see because I am unsure on what pyjnius statements you are referring to.. btw I am just a student developer creating our research application...
import certifi
import os
# segmentation
# import numpy as np
# import matplotlib.pyplot as plt
from kivy.uix.screenmanager import ScreenManager, Screen
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
from kivymd.uix.screen import MDScreen
from kivymd.app import MDApp
from kivymd.uix.filemanager import MDFileManager
from kivy.lang import Builder
# import cv2
from PIL import Image
os.environ['SSL_CERT_FILE'] = certifi.where() # certification
kv = '''
BoxLayout:
orientation: 'vertical'
MDTopAppBar:
title: "Prototype"
use_overflow: True
right_action_items:
[
["home-outline", lambda x: app.show_alert_dialog(), "Home", "Home"],
["account-group-outline", lambda x: app.show_alert_dialog(), "About us", "About us"],
["help-circle-outline", lambda x: app.show_alert_dialog(), "Help", "Help"],
]
elevation: 15
MDBottomAppBar:
MDTopAppBar:
icon: 'language-python'
mode: 'end'
type: 'bottom'
left_action_items: [["android", lambda x: app.show_alert_dialog()]]
FloatLayout:
Image:
id: image_path
source: 'x.png'
nocache: True
pos_hint:{'center_x': 0.5, 'center_y': 0.9}
size_hint: None, None
height: 550
width: 400
MDFillRoundFlatIconButton
icon: "button-pointer"
text: "Choose Image"
font_size: 40
pos_hint:{'center_x': 0.5, 'center_y': 0.5}
size_hint: 0.6, 0.3
on_release: app.open_file_manager()
MDFillRoundFlatIconButton
icon:"camera"
text: "Capture"
font_size: 40
pos_hint:{'center_x': 0.5, 'center_y': 0.3}
size_hint: 0.6, 0.3
on_release: app.show_alert_dialog()
'''
class WindowOne(Screen):
pass
class PrototypeApp(MDApp):
# permissions
from android.permissions import request_permissions, Permission
request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE])
def __init__(self, **kwargs):
super().__init__(**kwargs)
# popup init
self.dialog = MDDialog(
text="Feature not available yet!",
# radius=[20, 7, 20, 7],
)
# kv file init
self.main_widget = Builder.load_string(kv)
# file manager init
self.file_manager_obj = MDFileManager(
select_path=self.select_path,
exit_manager=self.exit_manager,
preview=True
)
def open_file_manager(self):
try:
from android.storage import primary_external_storage_path
primary_ext_storage = primary_external_storage_path()
self.file_manager_obj.show(primary_ext_storage)
except Exception:
self.dialog = MDDialog(
text=Exception,
radius=[20, 7, 20, 7],
)
def select_path(self, path):
print(path)
self.main_widget.ids.image_path.height = 500 # image size
self.main_widget.ids.image_path.width = 400 # ^^ ^^ ^^
self.main_widget.ids.image_path.reload() # refresh image
self.main_widget.ids.image_path.source = path # replace the old path to new path
self.exit_manager() # to go back to home screen after choosing
'''
try:
img = cv2.imread(path)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
h, w, c = img.shape
# resizing
if w > 1000:
new_w = 1000
ar = w / h
new_h = int(new_w / ar)
img = cv2.resize(img, (new_w, new_h), interpolation=cv2.INTER_AREA)
# cv2.imshow('Resized', img)
# cv2.waitKey(0)
plt.imshow(img)
plt.show()
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(img_gray, 80, 255, cv2.THRESH_BINARY_INV)
plt.imshow(thresh, cmap='gray')
plt.imshow(thresh);
plt.show()
# cv2.imshow('Black and White', thresh)
# cv2.waitKey(0)
# dilation
kernel = np.ones((3, 85), np.uint8)
dilated = cv2.dilate(thresh, kernel, iterations=1)
plt.imshow(dilated, cmap='gray');
(contours, heirarchy) = cv2.findContours(dilated.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
sorted_contours_lines = sorted(contours, key=lambda ctr: cv2.boundingRect(ctr)[1]) # (x, y, w, h)
img2 = img.copy()
for ctr in sorted_contours_lines:
x, y, w, h = cv2.boundingRect(ctr)
cv2.rectangle(img2, (x, y), (x + w, y + h), (40, 100, 250), 2)
plt.imshow(img2)
plt.show()
# cv2.imshow('Bounding Box', img2)
# cv2.waitKey(0)
kernel = np.ones((3, 15), np.uint8)
dilated2 = cv2.dilate(thresh, kernel, iterations=1)
plt.imshow(dilated2, cmap='gray');
img3 = img.copy()
words_list = []
for line in sorted_contours_lines:
# roi of each line
x, y, w, h = cv2.boundingRect(line)
roi_line = dilated2[y:y + w, x:x + w]
# draw contours on each word
(cnt, heirarchy) = cv2.findContours(roi_line.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
sorted_contour_words = sorted(cnt, key=lambda cntr: cv2.boundingRect(cntr)[0])
for word in sorted_contour_words:
if cv2.contourArea(word) < 400:
continue
x2, y2, w2, h2 = cv2.boundingRect(word)
words_list.append([x + x2, y + y2, x + x2 + w2, y + y2 + h2])
cv2.rectangle(img3, (x + x2, y + y2), (x + x2 + w2, y + y2 + h2), (255, 255, 100), 2)
plt.imshow(img3)
plt.show()
# cv2.imshow('Word by word', img3)
# cv2.waitKey(0)
ninth_word = words_list[8]
roi_9 = img[ninth_word[1]:ninth_word[3], ninth_word[0]:ninth_word[2]]
plt.imshow(roi_9);
plt.show()
except Exception as e:
print(e)
'''
# end image processing
def segmentation(self, img_path):
pass
def exit_manager(self):
self.file_manager_obj.close()
def navigation_draw(self):
print("Navigation Pressed!")
def build(self):
self.theme_cls.primary_palette = "Indigo"
self.theme_cls.theme_style = "Light"
return self.main_widget
# temp
def callback(self, instance_action_appbar_button):
print(instance_action_appbar_button)
def show_alert_dialog(self):
self.dialog.open()
# end temp
if __name__ == '__main__':
PrototypeApp().run()
To answer my question search for autoclass
, it does not exist in this file. So the answer is 'no'. This type of error is usually autoclass related, So next...
The use of request permissions, is probably a problem https://github.com/Android-for-Python/Android-for-Python-Users#user-permissions , its going to be called at class instantiation which violates the Kivy lifecycle https://kivy.org/doc/stable/guide/basic.html#kivy-app-life-cycle and presumably breaks Android too. The problem, I don't know; but breaking Android makes it a good candidate.
The file manager code is not going to work on any Android device > 10 See https://github.com/Android-for-Python/Android-for-Python-Users#android-storage
That should get you started. Happy to point you to the documentation, but I'm not the person to debug your code for you. This forum is for development issues, please post usage questions to the user groups.
Oh i see, i really appreciate your response sir this means a lot... Im going to close the thread for now and try to post this to google groups as you mentioned... Thank you very much for your time!
Versions
Description
Last month there was no problem building my application, it works on my android device specifically api31 Android 12 every feature I implemented with kivy,kivyMD etc. works like charm, i just dont know why in the last 2 weeks im getting a ''Android Fatal signal 11 (SIGSEGV) '' error SDLTHREAD, but the twist is my app works on my friends phone android 10 device...
buildozer.spec
Command:
Spec file:
Logs