Search code examples
androidflutterandroid-studiobuildcrash

build Apk on physical device crash android studio flutter


When I build my app on emulator (android 11 API 30) it's working fine, but when I try building on my old physical device (Android Kitkat API 19) It crash.

Edit : Yes developer options is enabled

But when I run terminal flutter build apk --split-per-abi or flutter run --release it works I can run it on physical device

I know I need armeabi v7 to make it work on my phone but its annoying to have to use console everytime I want to build

Unless I'm doing it wrong how do I build this on my IDE

Edit 2 : Here's my appbuild

minSdkVersion 19

buildTypes {
customDebugType {
        debuggable true
    }

    release {
        minifyEnabled true
        signingConfig signingConfigs.debug
    }

    debug {
        minifyEnabled true
        applicationIdSuffix ".debug"
        debuggable true
    }
    staging {
        initWith debug
        applicationIdSuffix ".debugStaging"
    }

Solution

  • You can add a custom run configuration to execute any shell script.

    To do so in Android Studio, go to Run -> Edit Configurations...

    Android Studio Edit Configurations... option

    In the configurations window, click the + icon and select Shell Script

    Configuration option menu in Android Studio

    Once it's added, you can give the script a name and for the "Script Path" select the flutter executable (This can be found inside the flutter SDK folder specifically inside a bin folder). For the "Script options", you can add the options you would like Flutter to execute such as build apk --split-per-abi or run --release

    Android Studio Shell Script Options

    At this point, you can click apply and ok. You should now see this custom runner in the drop down menu where you can run different tasks.

    Android Studio run option drop down