简体   繁体   中英

You have sent a signed APK or Android App Bundle in debug mode. Sign it in release mode. How to fix it (flutter)

I have to generate an APK to publish the app in Google Play Store, so I did this steps:

  • run keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key and paste the file key.jks inside android/app
  • create a file in android folder named key.properties with this content:
storePassword=myPass
keyPassword=myPass
keyAlias=KEY
storeFile=/app/key.jks
  • added this code in app/build.gradle:
def keystoreProperties = new Properties()
   def keystorePropertiesFile = rootProject.file('key.properties')
   if (keystorePropertiesFile.exists()) {
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
   }
  • Pasted this code in app/build.gradle:
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }

    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
        }
    }
  • Run flutter clean

  • Run flutter build apk --split-per-abi --release :

But when I send the apks to google play publish I receive this message:

You have sent a signed APK or Android App Bundle in debug mode. Sign it in release mode

What I need to do?

Remove the duplicate buildType release

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

Or rename to debug .

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
    debug {
        signingConfig signingConfigs.debug
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM