Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'

Viewed 1711

My Apologies for asking the question which has been already asked, the reason is I didn't get it, can anyone help me with this

here is the exception I got Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'. and app is unable to run emulator

D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:274: error: cannot find symbole\CloudFirestorePlugin.java:8: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:272: error: cannot find symbole\CloudFirestorePlugin.java:9: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:503: error: cannot find symbole\CloudFirestorePlugin.java:253: error: cannot find symbol
          public void onFailure(@NonNull Exception e) {
                                 ^
  symbol: class NonNull                                                                                                              e\CloudFirestorePlugin.java:558: error: cannot find symbol
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:274: error: cannot find symbol
                    public Void apply(@NonNull Transaction transaction)
                                       ^
  symbol: class NonNull
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:272: error: cannot find symbol
                    @Nullable
                     ^
  symbol: class Nullable
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:503: error: cannot find symbol
                    public void onFailure(@NonNull Exception e) {                                                                     full insights.
                                           ^
  symbol: class NonNull
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:558: error: cannot find symbol
                    public void onFailure(@NonNull Exception e) {
                                           ^
  symbol: class NonNull                                    
7 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.


BUILD FAILED in 5s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                         6.3s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin cloud_firestore...
The plugin cloud_firestore could not be built due to the issue above.

below are dependencies and plugins in the app/build.gradle file


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 29

    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 "com.example.smile"
        minSdkVersion 16
        targetSdkVersion 29
        multiDexEnabled true
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.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 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.google.firebase:firebase-analytics:17.2.2'
}

below are dependencies in andriod/build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}



The dependencies in pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  carousel_pro: ^1.0.0
  firebase_auth: ^0.6.6 
  cloud_firestore: any
  google_sign_in: ^4.1.4
  shared_preferences: ^0.5.6+2
  fluttertoast: ^3.1.3
  provider: 3.0.0
  flutter_svg: ^0.17.3+1
1 Answers

It seems that you are missing the firebase_core plugin, which is an essential package to use Firebase Core API.

Check this documentation for more info on using Firebase in Flutter.

Another possible reason could be the version of your cloud_firestore plugin, it might be conflicting with other dependencies. Use the latest version of your packages (e.g. cloud_firestore 3.1.0) and on your app/build.gradle, update the minSdkVersion 16 to minSdkVersion 23 as mentioned in this SO post.

Related