0

While connect my app with firebase generate SHA key app-level build.gradel shows an error in line 24 after adding google.json file I don't get where I am doing wrong line 24 starts from apply plugin. I upgrade flutter still I am getting this error -

def localProperties = new 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 new 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"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "mdhv.co.clone_flutter"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    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"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'

After run Flutter doctor don't get any issue then where is the problem?

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.10.3-pre.54, on Microsoft Windows [Version 10.0.18362.356], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.5)
[√] Connected device (1 available)

• No issues found!


mdhv_kothari
  • 627
  • 1
  • 7
  • 14
  • [Android Studio failed to apply plugin id com.android.application](https://stackoverflow.com/questions/37086806/android-studio-failed-to-apply-plugin-id-com-android-application) would this help at all? – sllopis Sep 17 '19 at 10:32
  • No man. I am getting this error after setup plugin of firebase – mdhv_kothari Sep 17 '19 at 16:25

1 Answers1

0

The error you've provided is complete, but build errors are usually caused by the added package not being installed correctly. Running flutter clean then flutter pub get should do the job. Also, depending on the Firebase products that you're using, you only need to use Firebase CLI and flutterfire_cli to setup Firebase in your Flutter project.

Omatt
  • 8,564
  • 2
  • 42
  • 144