'How to fix this issue ? FAILURE: Build failed with an exception
I try to add a package name as new_version: ^0.2.3. After the terminal return the below error. How can I fix this?
FAILURE: Build failed with an exception. Where: Build file 'D:\User\Projects\Flutter\apptech_beta-master.android\Flutter\build.gradle' line: 33
What went wrong: A problem occurred evaluating project ':flutter'.
Could not get unknown property 'compileSdkVersion' for extension 'flutter' of type FlutterExtension.
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.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
This is the build.gradle file
exception: Gradle task assembleStagingDebug failed with exit code 1
def flutterPluginVersion = 'managed'
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 30
buildToolsVersion = '30.0.2'
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
defaultConfig {
applicationId "com.app.app"
minSdkVersion 22
targetSdkVersion 30
versionCode 13
versionName "2.1"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
flavorDimensions "flavor"
productFlavors {
staging {
dimension "flavor"
}
}
}
buildDir = new File(rootProject.projectDir, "../build/host")
dependencies {
implementation project(':flutter')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation platform('com.google.firebase:firebase-bom:28.3.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.android.material:material:1.4.0'
}
enter code here
Solution 1:[1]
I met this issue and fixed it by modifying the format of file key.properties
.
You can try to comment on the following line (and the following signingConfigs
) to see if the build is success:
// keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
You can also reference the file local.properties
for what the correct format of the properties file should be (path should be 2 \
, no quotes...)
sdk.dir=C:\\Android\\sdk
flutter.sdk=C:\\src\\flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.versionCode=2
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 | yellowgray |