Search code examples
fluttergoogle-play-console

How to fix "Your Android App Bundle is signed with the wrong key"?


I'm trying to upload my appbundle but all the time I get this error "Your Android App Bundle is signed with the wrong key". I have already reseted my key with google, waited the 48h hours but I still got the error. I am using the new keystore.jks file on my key.properties, the same one I send as a pem file to google.

here is my key.properties:

storePassword=******
keyPassword=******
keyAlias=key
storeFile=/Users/ricardooscarkanitz/Projects/Apps/e_ai_casimiro_key/keystore.jks

and my 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.")    
   }

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
   flutterVersionCode = '2'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '2.0'
}

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

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 "br.com.kanitzdev.e_ai_casimiro"
    minSdkVersion 16
    targetSdkVersion 29
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true
 }

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


 buildTypes {
         release {
            signingConfig signingConfigs.debug
      }
    }
 }

 flutter {
     source '../..'
  }

dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

}

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

I have already tried to upload the key.jks file that I first got from keytool but it shows me the same error. Do you guys have any Idea on how to fix it?


Solution

  • You're still trying to generate the app bundle via the debug mode.

    Instead of : signingConfig signingConfigs.debug

    Try this : signingConfig signingConfigs.release