gpt4 book ai didi

android - VS Code/Flutter/Android - keystore 文件未设置用于签署配置版本

转载 作者:行者123 更新时间:2023-12-03 05:04:24 27 4
gpt4 key购买 nike

我按照这些步骤在 VS Code 上构建 apk:https://flutter.dev/docs/deployment/android

但我总是得到:

FAILURE:构建失败并出现异常。

  • 什么地方出了错:
    任务“:app:validateSigningRelease”执行失败。
  • 尝试:
    使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
  • https://help.gradle.org 获得更多帮助

  • 35 秒内构建失败
    正在运行 Gradle 任务“assembleRelease”...
    运行 Gradle 任务 'assembleRelease'... 完成 36,0s
    Gradle 任务 assembleRelease 失败,退出代码为 1

    我已经尝试在 build.gradle 上创建我的 key ,如下所示:
    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
    }
    }

    像这样:
    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
    }
    }

    但我在构建 apk 时遇到了同样的错误。
    官方文档似乎是错误的。
    如何在 VS Code 上创建 apk?

    最佳答案

    我只是有同样的错误。我认为 editing app/build.gradle 的文档有点困惑。

    这是我解决它的方法。注意重复的 buildTypes block 。

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

    这是我的完整 app/build.gradle(记得更改 applicationId)。
    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 = '1'
    }

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

    apply plugin: 'com.google.gms.google-services'
    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 28

    sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
    disable 'InvalidPackage'
    }

    defaultConfig {
    applicationId "!!!YOUR APP ID HERE!!!"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
    }

    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 {
    source '../..'
    }

    dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    }

    关于android - VS Code/Flutter/Android - keystore 文件未设置用于签署配置版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61944522/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com