【问题标题】:flutter building appbundle in release mode在发布模式下颤振构建 appbundle
【发布时间】:2021-04-14 19:32:24
【问题描述】:

我已经使用 android studio 在 Flutter 中构建了一个应用程序,并正在尝试在 Play 商店中发布它。

根据https://flutter.dev/docs/deployment/android#reviewing-the-build-configuration,“运行flutter build appbundle(运行颤振构建默认为发布构建。)”

但是,当我尝试在 Play 控制台上上传此内容时,我收到错误消息“您上传了在调试模式下签名的 APK 或 Android App Bundle。您需要在发布时签署您的 APK 或 Android App Bundle模式。”

我应该做些什么不同的事情?

来自我的 gradle.build:


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 "com.rtterror.custom_snooze_alarm"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

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

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

【问题讨论】:

    标签: android android-studio flutter google-play


    【解决方案1】:

    Flutter 可以选择构建一个appbundle

    flutter build appbundle
    

    我的参考来自这个github project

    【讨论】:

      【解决方案2】:

      尝试修改您的 buildTypes 块。

      buildTypes {
          release {
              signingConfig signingConfigs.release
          }
      }
      

      【讨论】:

        【解决方案3】:

        确保您的密钥库文件已正确设置并在“Android/key.properties”中引用。这是创建密钥库的命令: keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

        然后运行flutter clean && flutter build appbundle --release

        如果您遇到同样的错误,请尝试以下有用的演练:https://medium.com/@psyanite/how-to-sign-and-release-your-flutter-app-ed5e9531c2ac

        【讨论】:

          猜你喜欢
          • 2020-07-07
          • 2022-07-12
          • 2020-12-25
          • 2023-03-23
          • 1970-01-01
          • 1970-01-01
          • 2023-03-28
          • 2019-11-28
          • 2019-07-12
          相关资源
          最近更新 更多