'flutter Could not get unknown property 'release' for SigningConfig container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer

Whenever I try to run my code this error pops up:

> Could not get unknown property 'release' for SigningConfig container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.

I have try to use this

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

still, yet I cant run my code......

thanks in advance.



Solution 1:[1]

try adding this in your app/build.gradle at the top of android {...}

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

Then after generate .jsk file following tutorial

https://medium.com/@psyanite/how-to-sign-and-release-your-flutter-app-ed5e9531c2ac

Solution 2:[2]

Add in variants

buildTypes {
        release {
            minifyEnabled false
            signingConfig signingConfigs.release
        }
        debug {
            debuggable true
            signingConfig signingConfigs.release
        }
    }

Do not add in

defaultConfig {
  .
  .
  signingConfig signingConfigs.release
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Bipin