51

I am trying to upload an Application on the Google Play store. I am building the .apk and signing it using Maven. I have used maven-jarsigner-plugin to sign the .apk file. I am using the key that I created using Eclipse wizard for signing another Android app. I zipalign the .apk file using the following command: zipalign [-f] [-v] infile.apk outfile.apk

When I try to uplaod the application on the playstore, I get the error You uploaded an APK that was signed in debug mode. You need to sign your APK in release mode. Can anyone please tell me how to sign the apk in release mode? I am new to Maven (started using it today). Thanks

Nemin
  • 1,907
  • 6
  • 24
  • 37
  • See if the answer [here](http://stackoverflow.com/questions/15055961/android-maven-plugin-disable-debug-build-for-apk/15056758#15056758) helps. – yorkw May 30 '13 at 22:00
  • I have the same problem using unity https://stackoverflow.com/questions/60603203/unityyou-uploaded-an-apk-or-android-app-bundle-that-was-signed-in-debug-mode-y – INDRAJITH EKANAYAKE Mar 09 '20 at 16:32

8 Answers8

78

Change to: signingConfig signingConfigs.release

from signingConfig signingConfigs.debug

in your build.gradle app level

Asty
  • 797
  • 1
  • 5
  • 3
  • 6
    I spent hours dealing with this while trying to deploy a Flutter app, this definitely needs to be better documented, a simple TODO in the file is just not enough... thanks! – mchurichi Jul 01 '20 at 06:37
  • 1
    @mchurichi Actually it is documented here https://flutter.dev/docs/deployment/android#configure-signing-in-gradle , but I missed it too – lordvcs Sep 08 '20 at 21:46
  • 6
    Does not work for me, gave `Could not get unknown property 'release' for SigningConfig container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.` upon running `flutter build apk --release` – Harsh Phoujdar Aug 09 '21 at 22:07
22

Go to android/app/build.gradle

At the end of the file:

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 <==== change this to release
    }
}

Resul should be like:

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
    }
}
K.Amanov
  • 1,278
  • 14
  • 23
15

I don't know how you do that in Maven, but you need to compile your app with a release keystore. You can create one with keytool, which is available in your Java bin folder:

$ keytool -genkey -v -keystore my-release-key.keystore
-alias alias_name -keyalg RSA -keysize 2048 -validity 10000

When creating it, you must supply two passwords, one for the keystore and one for the key. When your keystore is created, you can use the Eclipse Export wizard to compile your app in release mode.

For further details, please refer to http://developer.android.com/tools/publishing/app-signing.html#releasemode

Piovezan
  • 3,215
  • 1
  • 28
  • 45
  • The problem is that I dont want to use Eclipse to compile the app. I tried that and was able to do that without any problem. I need to compile it using Maven, – Nemin May 22 '13 at 00:08
  • This is the correct explanation, just use this generated keystore on maven! – thiagolr May 23 '13 at 12:33
7

Always create your keystore with name and alias containing "release" not "debug". If you are having the "You uploaded an APK that was signed in debug mode. You need to sign your APK in release mode error" it's certain that you are using default keystore which is 'debug.keystore' hence generating apk in debug mode.

Solution

  1. Generate new keystore
  2. Give reference in build.gradle file
  3. Change build variant to 'release'
  4. Build

this should fix the issue.

ZygoteInit
  • 485
  • 6
  • 9
7

For flutter error, By default flutter creates buildtypes like below

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

you should change the signingconfig line

        signingConfig signingConfigs.release
Anand
  • 4,355
  • 2
  • 35
  • 45
5

I had the same issue with my flutter app,

Add these to your android/app/build. Gradle:

before android { compileSdkVersion 30

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

And after defaultConfig {

}
signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}
yendis
  • 318
  • 5
  • 12
2

Follow this documentation exactly and it will work (at least it worked for me...)

Niels
  • 1,366
  • 15
  • 21
0

Using -genkeypair instead of -genkey solved the problem for me.

So: keytool -genkeypair -keystore name.keystore -alias nameapp -keyalg RSA

romain ni
  • 219
  • 1
  • 4