繁体   English   中英

您已在调试模式下发送了签名的 APK 或 Android App Bundle。 在发布模式下签名。 如何修复它(颤振)

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

我必须生成一个 APK 才能在 Google Play 商店中发布应用程序,所以我执行了以下步骤:

  • 运行keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key并将文件 key.jks 粘贴到 android/app
  • 在 android 文件夹中创建一个名为key.properties的文件,其中包含以下内容:
storePassword=myPass
keyPassword=myPass
keyAlias=KEY
storeFile=/app/key.jks
  • 在 app/build.gradle 中添加了这段代码:
def keystoreProperties = new Properties()
   def keystorePropertiesFile = rootProject.file('key.properties')
   if (keystorePropertiesFile.exists()) {
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
   }
  • 将此代码粘贴到 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
        }
    }
  • 运行flutter clean

  • 运行flutter build apk --split-per-abi --release

但是,当我将 apk 发送到 google play publish 时,我会收到以下消息:

您已在调试模式下发送了签名的 APK 或 Android App Bundle。 在发布模式下签名

我需要做什么?

删除重复的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
        }
    }

或重命名为debug

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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