1

I have built a release android apk file, conceived for a size of 7.9 MB. I manage to install it on my android device, but not to open it because it crashes. When i use flutter run --release it still does not open and detects no errors.

How can I solve that problem? Thank you for your help.

Note: I have found several questions close to mine, but they have an error or are not entirely similar to mine. As a consequence the solution given do not work on my case.

Here is some of my build.gradle

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
        checkReleaseBuilds false
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.misteref.mykamus"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

   signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile file(keystoreProperties['storeFile'])
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
           useProguard true
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
           signingConfig signingConfigs.release
       }
   }
}
Adam Theory
  • 103
  • 3
  • 12

3 Answers3

1

in app level build.gradle set minifyEnabled and shrinkResources to false or use progaurd if you need this two be true

buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
Amir
  • 2,225
  • 2
  • 18
  • 27
1

To expand on @Joachim Haglund's comment

update your gradle file with the following. All the builds will then be included in the aab file. (It's also worth checking what SDKs you have installed/require updating with Android Studio)

android {
    defaultConfig {
        //add the following
        ndk {
            abiFilters "x86", "x86_64", "armeabi", "armeabi-v7a", "arm64-v8a"
        }
    }
}
F-1
  • 2,887
  • 20
  • 28
  • what are these errors? I can't help if you don't provide details. Did you check you have NDKs installed in android studio? – F-1 Oct 14 '19 at 14:39
  • i mean errors when i use flutter build apk --split-per-abi , but no errors when i use flutter build apk --release. but still, it can open the app in my android device – Adam Theory Oct 14 '19 at 14:51
  • why are you building apk individually instead of using the app bundle function? Are you building from Visual Studio Code or Android Studio, what happens when you build using the other application? – F-1 Oct 14 '19 at 15:32
0

I was running into this issue with alternative resolution where, as described in this SO thread, my flutter app was able to run in release mode by adding the following dependency in my build.gradle file:

implementation 'androidx.work:work-runtime-ktx:2.7.1'

This fix is applicable if you see an error message like

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
mcsj120
  • 89
  • 1
  • 3