'Kivy app crashes on android with error module not found sklearn

I have made simple machine learning app which predicts crop for soil report inputs . It works totally fine on windows but however when converted to apk using bulldozer tool with all required requirements it crashes with logcat error module not found sklearn , I have added sklearn in requirements of buildozer.spec file

Python code*

class SoilTest(Screen):
    location = ObjectProperty()
    nitrogen = ObjectProperty()
    phosphorus = ObjectProperty()
    potassium = ObjectProperty()
    rain_fall = ObjectProperty()
    ph  = ObjectProperty()
    temp = ObjectProperty()
    humidity = ObjectProperty()
    def submit_result(self):
        global humi
        humi=self.humidity.text
        o=open("loc.csv","+a")
        p = o.write(humi) 
        humi = float(humi)
        global tem
        tem=self.temp.text
        p = o.write("\t")
        p = o.write(tem)
        tem=float(tem)
        global p_h 
        p_h = self.ph.text
        p = o.write("\t")
        p = o.write(p_h)
        p_h=float(p_h)
        global fall
        fall = self.rain_fall.text
        p = o.write("\t")
        p = o.write(fall)
        fall=float(fall)
        global pota
        pota = self.potassium.text
        p = o.write("\t")
        p = o.write(pota)
        pota=float(pota)
        global phos
        phos = self.phosphorus.text
        p = o.write("\t")
        p = o.write(phos)
        phos=float(phos) 
        loc = self.location.text
        data1 = o.write(loc)
        global nitro
        nitro = self.nitrogen.text
        n = o.write('\t')
        n = o.write(nitro) 
        nitro=float(nitro) 
        o.close()
    def recommand(self):
        x = [[nitro,phos,pota,tem,humi,p_h,fall]]
        y_pred = mode.predict(x);
        global cropi
        cropi=(crop_name[y_pred[0]])
        cropi=str(cropi)
        print(cropi)

Kivy Code

<SoilTest>:
    name:'soiltest'
    location: loc
    nitrogen: nitro
    phosphorus: phosp
    potassium: pota
    rain_fall: rain
    ph: pih
    temp: temper
    humidity: humi
    BoxLayout:
        orientation:'vertical'
        MDTextField:
            id: loc
            hint_text:"Enter Location"
            helper_text:"parameters"
            icon_right:'android'
            helper_text_mode:"on_focus"
            icon_right_color: app.theme_cls.primary_color
            pos_hint:{"center_x":0.5,"center_y":0.9}
            size_hint_x:None
            width:300
        MDTextField:
            id: nitro
            hint_text:"Enter Nitrogen"
            helper_text:"parameters"
            icon_right:'android'
            helper_text_mode:"on_focus"
            icon_right_color: app.theme_cls.primary_color
            pos_hint:{"center_x":0.5,"center_y":0.8}
            size_hint_x:None
            width:300
        MDTextField:
            id: phosp
            hint_text:"Enter Phosphorus"
            helper_text:"parameters"
            icon_right:'android'
            helper_text_mode:"on_focus"
            icon_right_color: app.theme_cls.primary_color
            pos_hint:{"center_x":0.5,"center_y":0.7}
            size_hint_x:None
            width:300
        MDTextField:
            id: pota
            hint_text:"Enter Potasium"
            helper_text:"parameters"
            icon_right:'android'
            helper_text_mode:"on_focus"
            icon_right_color: app.theme_cls.primary_color
            pos_hint:{"center_x":0.5,"center_y":0.6}
            size_hint_x:None
            width:300
        MDTextField:
            id: rain
            hint_text:"Enter Rain_fall"
            helper_text:"parameters"
            icon_right:'android'
            helper_text_mode:"on_focus"
            icon_right_color: app.theme_cls.primary_color
            pos_hint:{"center_x":0.5,"center_y":0.5}
            size_hint_x:None
            width:300
        MDTextField:
            id: pih
            hint_text:"Enter PH of soil"
            helper_text:"parameters"
            icon_right:'android'
            helper_text_mode:"on_focus"
            icon_right_color: app.theme_cls.primary_color
            pos_hint:{"center_x":0.5,"center_y":0.4}
            size_hint_x:None
            width:300
        MDTextField:
            id: temper
            hint_text:"Enter Temprature"
            helper_text:"parameters"
            icon_right:'android'
            helper_text_mode:"on_focus"
            icon_right_color: app.theme_cls.primary_color
            pos_hint:{"center_x":0.5,"center_y":0.3}
            size_hint_x:None
            width:300
        MDTextField:
            id: humi
            hint_text:"Enter Humidity"
            helper_text:"parameters"
            icon_right:'android'
            helper_text_mode:"on_focus"
            icon_right_color: app.theme_cls.primary_color
            pos_hint:{"center_x":0.5,"center_y":0.2}
            size_hint_x:None
            width:300
        # BoxLayout:
        #     orientation:'vertical'
        BoxLayout:
            orientation:'horizontal'
            MDFillRoundFlatButton:
                text:"Submit"
                pos_hint:{"center_x":.4,"center_y":.4}
                size_hint_x:None
                on_release:
                    root.submit_result()
                    root.recommand()
                    # (nitro,phosp,pota,temper,humi,pih,rain)
                    app.root.current='result'
            BoxLayout:
                orientation:'horizontal'        
            MDFillRoundFlatButton:
                text:"Back"
                pos_hint:{"center_x":.4,"center_y":.4}
                size_hint_x:None
                on_release:
                    app.root.current='first'

Here is the images of app logcat Logcat

Here are some ss of app with submit button after pressing this it crashes on android but works fine on windows

Soil reports

Predicted crop by app crop



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source