I’m trying to build a Flutter application for Android using the flutter build apk command, but the build fails with the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':firebase_core'.
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':firebase_core' of type org.gradle.api.Project.
> Could not get unknown property 'android' for project ':firebase_core' of type org.gradle.api.Project.
* 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 953ms
Running Gradle task 'assembleRelease'... 1.604ms
Gradle task assembleRelease failed with exit code 1
I try with this configurations
Configuration Files
settings.gradle
include ':app'
include ':firebase_core'
project(':firebase_core').projectDir = new File(rootProject.projectDir, '../../AppData/Local/Pub/Cache/hosted/pub.dev/firebase_core-3.9.0/android')
Project-level build.gradle
buildscript {
ext {
compileSdkVersion = 33
minSdkVersion = 21
targetSdkVersion = 33
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'com.google.gms:google-services:4.3.15'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
App-level build.gradle
android {
compileSdkVersion 33
defaultConfig {
applicationId "com.gustaga.app"
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
}
buildTypes {
release {
signingConfig signingConfigs.debug
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source = "../.."
}
dependencies {
implementation project(':firebase_core')
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation 'com.google.firebase:firebase-database:20.0.5'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
firebase_core build.gradle
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 33
defaultConfig {
minSdkVersion 21
targetSdkVersion 33
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies {
implementation 'com.google.firebase:firebase-core:21.1.1'
}
i’ve ensured that all the configurations are correct, but the issue persists. Any help would be greatly appreciated!
New contributor
Cristian Osorio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.