I’m getting a build error in the build.gradle file on line #11.
I have removed the "new" keyword from the file but I still get the error.
Here is my build.gradle file:
def localProperties = Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.natekane.deal_diligence"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.natekane.deal_diligence"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform("com.google.firebase:firebase-bom:32.3.1")
}
Here is the full error message from the debug window:
Build file 'C:deal_diligenceandroidbuild.gradle' line: 11
* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method id() for arguments [com.google.gms.google-services] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Everything I have found so far says for me to delete the "new" keyword.
I am trying to add Firebase to the app so maybe I messed up the other build.gradle file too?
What else can I do?
Thanks
2
Answers
Thank you for your help. I was able to get past this error by making the change to my android/build.gradle file and I needed to add the "new" key word to line 1 in my app/build.gradle file.
The error already stated that error at ‘Build file ‘C:deal_diligenceandroidbuild.gradle’ line: 11"
Which means in android/build.gradle file, but you sharing us the app/build.gradle file.
Try check the android/build.gradle file and add below line inside the dependencies {…} if not you haven’t :