29

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' 
3
  • Could you share your app/build.gradle file ? Commented Aug 4, 2018 at 19:28
  • Done, just added. AFAIK no changes have been made to anything, I discovered this a day or so ago and it affects every single Flutter project I'm working on, even a new project from scratch Commented Aug 4, 2018 at 19:42
  • I've the same problem with @kenwen, I've tried a few ways but also not working. The first way I try to amend my build buildTypes from debug to release signingConfig signingConfigs.release and upload to Google Play Console, it prompts me that my app bundle was signed in debug mode. The second way I tried is using command flutter build appbundle --release to build my appbundle. After I upload to Google Play Console, it still prompts me that my app bundle was signed in debug mode. The two solutions I tried also not working. Anyone have any idea or experience before? Appreciate! Commented Jul 11, 2023 at 1:45

7 Answers 7

53

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

Here you can find more info: https://docs.flutter.dev/deployment/android

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, just read through docs again with more attention and caught that. I'm just curious as to why I was able to sign and publish release versions before today. Mark me down as confused
Note (from flutter docs): You may need to run flutter clean after changing the gradle file. This prevents cached builds from affecting the signing process.
11

You also need to change

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

to

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

in the file android/app/build.gradle

Comments

8

The problem is marked in red. You have copied the first part, which is signedConfigs. But didn't changed 'debug' to 'release'. NASA revealed that this happens when you are in a real hurry and can't see some of the minute details in the documentation and need to build and release the project as soon as possible. I was like that.

Screenshot from the documentation page, https://flutter.dev/docs/deployment/android

Flutter build

Comments

2

In android/app/build.gradle change the signingConfig signingConfigs.debug to signingConfig signingConfigs.release which you can find under buildTypes

Comments

0

You'll have to generate an upload key and keystore.

In the menu bar, click Build > Generate Signed Bundle/APK.

In the Generate Signed Bundle or APK dialog, select Android App Bundle or APK and click Next.

Below the field for Key store path, click Create new.

Fill-in the required fields : path, password, key, password, validity years, certificate details (name, org unit, etc.)

Click Ok.

To build, go to menu > Build > Generate Signed Bundle/APK.

Select release mode and don't forget to check on both V1 and V2 enter image description here

The above information is taken from Android Developer User Guide

Comments

0

file path: android/app/build.gradle

search for signingConfig signingConfigs.debug and replase with signingConfig signingConfigs.release

enter image description here

Comments

0

Got the answer here 1- go to android folder in Android studio 2- go to app folder 3- in you build.grade instead of this

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

put this

signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile keystoreProperties['LOCATION OF JKS FILE'] ? file(keystoreProperties['LOCATION OF JKS FILE']) : null storePassword keystoreProperties['storePassword'] } } buildTypes { release { signingConfig signingConfigs.release } } 

in LOCATION OF JKS FILE you should put the location of your key file NOTE: Dont forget to generate key before if you don't have use this:

On Mac/Linux, use the following command:

content_copy keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload 

On Windows, use the following command:

content_copy keytool -genkey -v -keystore %userprofile%\upload-keystore.jks -storetype JKS -keyalg RSA 

See here for more (https://docs.flutter.dev/deployment/android)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.