skip to Main Content

I failed to build flutter app.

I wrote in tarminal of VSCode.

`flutter build appbundle –release““

but failed.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:UsersNAMEsourcereposNAMEworkflutterAPP_NAMEandroidappbuild.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’ line: 58 is a line starts from keyAlias…

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

I added these code at androidappbuild.gradle

enter image description here

and I made androidappkey.jks

and I modified androidkey.properties

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

2

Answers


  1. Chosen as BEST ANSWER

    The problem was solved.

    
    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"
    
    

  2. You need to add code like this to initialize the keystoreProperties, for example below the other "def" statements at the top of the file:

    def keystoreProperties = new Properties()
    def keystorePropertiesFile = file('/path/to/your/key.properties')
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search