Android – Google Play error when uploading Flutter app debuggable

androidfluttergoogle-play-console

I've been using Google Play app signing, Flutter and VS Code without problems for a while now but since yesterday, every release build for every single Flutter project I'm working on keeps hitting an error and reporting that I'm trying to upload a debug build.

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

Even a new app is having same problem

I've cleaned the build folder out, I've used the –release flag, neither option worked.

One thing I'd like to try is manually compiling app, manually signing then uploading but can't work out how to do this.

Any suggestions? Tearing hair out as I can't think of any changes recently that could affect this.

flutter doctor output – only bit of weirdness is that VS Code flutter extension is missing – it's not :-/

✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.6 17G65, locale
en-GB)
• Flutter version 0.5.1 at /Users/kenwen/Dev Tools/flutter
• Framework revision c7ea3ca377 (10 weeks ago), 2018-05-29 21:07:33 +0200
• Engine revision 1ed25ca7b7
• Dart version 2.0.0-dev.58.0.flutter-f981f09760

[✓] Android toolchain – develop for Android devices (Android SDK
28.0.1)
• Android SDK at /Users/kenwen/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.

[✓] iOS toolchain – develop for iOS devices (Xcode 9.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4.1, Build version 9F2000
• ios-deploy 1.9.2
• CocoaPods version 1.5.2

[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 27.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[!] VS Code (version 1.25.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[!] Connected devices
! No devices available

! Doctor found issues in 2 categories.

build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location 
with flutter.sdk in the local.properties file.")
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID 
(https://developer.android.com/studio/build/application-id.html).
        applicationId "uk.co.kenliu.meanfitfoxes"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 21
        versionName "1.7.9"
        testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
    }

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

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }

apply plugin: 'com.google.gms.google-services'

Best Answer

You have to create your signing config for release mode, in your current file your are using signing config from debug.

 buildTypes {
    release {
        signingConfig signingConfigs.debug   //for this reason google doesn't allow you to upload the apk
    }
}

Create a signing configuration inside your gradle file :

        android {
            ...
            signingConfigs {
                release {
                    storeFile file("release.keystore")
                    storePassword "******"
                    keyAlias "******"
                    keyPassword "******"
                }
            }
            buildTypes {
                release {
                    signingConfig signingConfigs.release
                }
            }
        }
Related Topic