Bashar
Bashar

Reputation: 13

Execution failed for task ':app:packageRelease'

FAILURE: Build failed with an exception.

A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable SigningConfig "release" is missing required property "storeFile".

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 FAILED in 27s Running Gradle task 'assembleRelease'... 28.7s Gradle task assembleRelease failed with exit code 1 Process finished with exit code 1

it didn't work with flutter clean , flutter pub get

it happens when i try to build APK file

Upvotes: 1

Views: 428

Answers (1)

Faisal Ahmed
Faisal Ahmed

Reputation: 1106

Problem: This error occurs when the release build configuration lacks the storeFile property in the SigningConfig. This property is essential for signing the APK during the build process.

Solution:

Step 1: Locate the build.gradle File Open your project in Android Studio or your preferred IDE. Go to the android/app directory. Open the build.gradle file.

Step 2: Add or Update the SigningConfig for Release Ensure you have a signingConfigs block in your build.gradle file:

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

}

Step 3: Create or Update the key.properties File In the android directory, create a key.properties file (if it doesn’t exist). Add the following:

storePassword=your_store_password
keyPassword=your_key_password
keyAlias=your_key_alias
storeFile=path_to_your_keystore_file

Step 4: Load the key.properties File in build.gradle Ensure your build.gradle file loads the key.properties file:

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

Step 5: Reference the SigningConfig in the Build Types Make sure the release build type references the signingConfig:

buildTypes {
release {
    signingConfig signingConfigs.release
    minifyEnabled false // or true based on your needs
    // Add other configurations here
}

}

Step 6: Rebuild the Project Run flutter clean.

Run flutter pub get.

Build your APK again with:flutter build apk --release

Note: If you don’t have a keystore, generate one with:

keytool -genkey -v -keystore your_keystore_name.jks -keyalg RSA -keysize 2048 -validity 10000 -alias your_key_alias

Upvotes: 1

Related Questions