当前位置: 首页 > 知识库问答 >
问题:

VS code/flutter/android-keystore文件未设置用于签名配置版本

宇文峰
2023-03-14
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代码上创建apk?

共有1个答案

姜鸿
2023-03-14

我只是犯了同样的错误。我认为编辑app/build.gradle的文档有点混乱。

这是我如何解决的。注意重复的buildTypes块。

    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'
}
 类似资料:
  • 在Gradle for Android中,为发布版本定义签名配置似乎是常见的做法,如下所示: 问题是,我想把我的build.gradle文件保存在版本控制中,并且在一些git服务器上没有我的密钥库的密码(这与我用于其他东西的密码相同,愚蠢的,我知道)没有好的感觉。 有没有办法从硬盘驱动器上的某个位置从外部文件加载签名配置?

  • 本文向大家介绍iOS mobileconfig配置文件进行签名的配置方法,包括了iOS mobileconfig配置文件进行签名的配置方法的使用技巧和注意事项,需要的朋友参考一下 配置描述文件(.mobileconfig) 是XML文件,包含设备安全策略、VPN配置信息、Wi-Fi设置、APN设置、Exchange帐户设置、邮件设置以及允许iPhone和iPod touch与企业系统配合使用的证书

  • 我们正在从WebSphere Liberty Profile(8.5.5.6)REST服务访问一个外部服务,该服务使用Apache HTTPClient 4.3.5连接到该服务。 该服务刚刚更改为使用TLS v1。现在我们的服务失败了:[4/21/16 12:23:37:596 EDT]000000 5D bm。myw3。服务。awf。sso。ejb。发电机SSOTokeneratorImpl I

  • 问题内容: 我有一个使用maven作为构建工具的应用程序。 我正在使用Maven配置文件从不同的配置文件设置不同的属性。 我想做的是将maven中的所有活动配置文件也移植到spring活动配置文件中,以便我可以在bean签名()中引用它们。但我不确定该怎么做。 例如:考虑以下Maven设置 假设我在未指定任何其他配置文件的情况下运行maven,而我希望spring具有和 配置为活动配置文件。 问题

  • 我有一个用maven作为构建工具的应用程序。 我正在使用maven概要文件从不同的概要文件设置不同的属性。 假设我运行带有out的maven,并指定我希望spring的任何其他概要文件,将和作为活动概要文件。