The flutter app does not build in android studio

207

Add this at the bottom of your android/app/build.gradle

apply plugin: 'com.google.gms.google-services'
Share:
207
anna
Author by

anna

Updated on January 04, 2023

Comments

  • anna
    anna over 1 year

    I'm trying to build my flutter app in android studio, but I'm getting the following error. Unfortunately, google failed to turn up this error from other developers. I would be glad to hear your ideas!

    Execution failed for task ':app:mapDebugSourceSetPaths'.

    Error while evaluating property 'extraGeneratedResDir' of task ':app:mapDebugSourceSetPaths' Failed to calculate the value of task ':app:mapDebugSourceSetPaths' property 'extraGeneratedResDir'. > Querying the mapped value of provider(interface java.util.Set) before task ':app:processDebugGoogleServices' has completed is not supported

    Here is build.gradle(:app)

    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: 'kotlin-android'
    apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
    apply plugin: 'com.google.gms.google-services'
    
    
    
    android {
        compileSdkVersion 31
    
        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.everybodytalks"
            minSdkVersion 16
            targetSdkVersion 31
            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"
        // Import the Firebase BoM
        implementation platform('com.google.firebase:firebase-bom:29.2.0')
    
    
    } 
    

    Here is build.gradle(:app)

    buildscript {
        ext.kotlin_version = '1.6.10'
        repositories {
            google()
            mavenCentral()
    
    
        }
    
        dependencies {
    
    
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.android.tools.build:gradle:7.3.0-alpha05'
            classpath 'com.google.gms:google-services:4.3.10'
    
        }
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
    
    
        }
    }
    
    rootProject.buildDir = '../build'
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
        project.evaluationDependsOn(':app')
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
  • anna
    anna about 2 years
    Dear Rohith,thank you so much for your input! I did it, but unfortunately I get the same error.
  • Rohith Nambiar
    Rohith Nambiar about 2 years
    I see that your build.gradle(:app) file already has this line, try removing this line in both places
  • anna
    anna about 2 years
    Sadly, it didn't work. Now there is another error: Android resource linking failed error: resource style/Theme.MaterialComponents.Light.NoActionBar (aka com.everybodytalks:style/Theme.MaterialComponents.Light.NoAc‌​tionBar) not found. error: resource style/Theme.MaterialComponents.DayNight.NoActionBar (aka com.everybodytalks:style/Theme.MaterialComponents.DayNight.N‌​oActionBar) not found. error: failed linking references.
  • Rohith Nambiar
    Rohith Nambiar about 2 years
    Hmm, I think it fixed the first error, try researching for solutions regarding the second error.
  • anna
    anna about 2 years
    Thank you so much! This is exactly what I needed to do!
  • Rohith Nambiar
    Rohith Nambiar about 2 years
    Happy to help, you can accept the answer if it helped you