android 扑动-失效:生成失败,出现异常,对于发布版本

ruarlubt  于 2023-05-05  发布在  Android
关注(0)|答案(2)|浏览(185)

我无法创建Flutter应用程序。
我写在VSCode的最后。
flutter build appbundle --release
但失败了

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\NAME\source\repos\NAME\work\flutter\APP_NAME\android\app\build.gradle' line: 58

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'keystoreProperties' for SigningConfig$AgpDecorated_Decorated{name=release, storeFile=null, storePassword=null, keyAlias=null, keyPassword=null, storeType=pkcs12, v1SigningEnabled=true, v2SigningEnabled=true, enableV1Signing=null, enableV2Signing=null, enableV3Signing=null, enableV4Signing=null} of type com.android.build.gradle.internal.dsl.SigningConfig$AgpDecorated.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

build.gradle'行:58是从keyAlias开始的一行…

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

我在android\app\build.gradle添加了这些代码
enter image description here
我做了android\app\key.jks
android\key.properties

storePassword=MYPASSWORD
keyPassword=MYPASSWORD
keyAlias=key
storeFile=key.jks
whhtz7ly

whhtz7ly1#

你需要添加这样的代码来初始化keystoreProperties,例如在文件顶部的其他“def”语句下面:

def keystoreProperties = new Properties()
def keystorePropertiesFile = file('/path/to/your/key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
s4n0splo

s4n0splo2#

问题解决了。

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

////////////////////////////
// inserted here

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

////////////////////////////

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

相关问题