Search code examples
androidfluttergoogle-play-console

Flutter release apk not accepted by Google Play Console


I created a key and keystore and signed my apk, following the instructions step by step from the official flutter page.

But when I try to upload it to Google Play Console, I get this error:

"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"

A similar question is asked before, but it did not solve my issue.

Here is the relevant part of my app/build.gradle:

android {
compileSdkVersion 28

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "my.package.name"
    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

        minifyEnabled true
        useProguard true

        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

Here is the screenshot of my Android Studio versions (Android SDK being red is not relevant.):

Screenshot of Android Studio showing the used versions.

My output.json file:

[
  {
    "outputType": {
      "type": "APK"
    },
    "apkInfo": {
      "type": "MAIN",
      "splits": [
        
      ],
      "versionCode": 1,
      "versionName": "1.0.0",
      "enabled": true,
      "outputFile": "app-release.apk",
      "fullName": "release",
      "baseName": "release"
    },
    "path": "app-release.apk",
    "properties": {
      
    }
  }
]

Solution

  • No suggestions seemed to be working. Then, a

    flutter clean

    and all issues were solved. I could create an apk either through Android Studio or the command line. Thanks to VikaS and Harsha pulikollu