Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter building appbundle in release mode

I have built an app in flutter using android studio and am trying to release it on the play store.

According to https://flutter.dev/docs/deployment/android#reviewing-the-build-configuration, "Run flutter build appbundle (Running flutter build defaults to a release build.)" enter image description here enter image description here

However, when I try to upload this on the play console, I get the error message that "You uploaded an APK or Android App Bundle that was signed in debug mode. You need to sign your APK or Android App Bundle in release mode." enter image description here

What should I do differently?

From my gradle.build:


def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 29

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

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.rtterror.custom_snooze_alarm"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}
like image 666
nickt Avatar asked Jan 09 '21 06:01

nickt


People also ask

How do you make apps in release mode in flutter?

To compile in release mode, we just need to add the --release flag to the flutter run command and have a physical device connected. Although we can do so, we typically do not use the flutter run command with the --release flag.


1 Answers

Try modifying your buildTypes block.

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}
like image 62
abdiwan Avatar answered Sep 27 '22 21:09

abdiwan