2
votes

In my flutter project, my cloud firestore started causing a compilation error. I started again a project without code, just by bringing my dependences. But I still have the same mistake:

/home/jeremy/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.9.13/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:171: error: cannot find symbol
        query = query.whereArrayContains(fieldName, value);
                     ^
  symbol:   method whereArrayContains(String,Object)
  location: variable query of type Query
/home/jeremy/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.9.13/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:627: error: cannot find symbol
            builder.setTimestampsInSnapshotsEnabled(
                   ^
  symbol:   method setTimestampsInSnapshotsEnabled(Boolean)
  location: variable builder of type Builder
/home/jeremy/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.9.13/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:707: error: cannot find symbol
        return FieldValue.arrayUnion(toArray(readValue(buffer)));
                         ^
  symbol:   method arrayUnion(Object[])
  location: class FieldValue
/home/jeremy/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.9.13/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:709: error: cannot find symbol
        return FieldValue.arrayRemove(toArray(readValue(buffer)));
                         ^
  symbol:   method arrayRemove(Object[])
  location: class FieldValue
Note: /home/jeremy/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.9.13/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 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.

* 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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1

My dependencies

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  firebase_core: ^0.3.4
  firebase_auth: ^0.8.4+2
  cloud_firestore: ^0.9.13
  firebase_storage: ^2.1.0+1
  firebase_ml_vision: ^0.7.0
  firebase_analytics: ^2.1.1
  device_info: ^0.4.0+1
  cached_network_image: ^0.7.0
  image_picker: ^0.5.2
  shared_preferences: ^0.5.1+2
  google_sign_in: ^4.0.1+3
  connectivity: ^0.4.2+2
  cupertino_icons: ^0.1.2

build.gradle :

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

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

allprojects {
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.google.firebase') {
                details.useVersion "15.+"
            }
        }
    }
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle :

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 "com.youpa.youpa"
        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'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-auth:16.2.0'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true


I tried to follow the information in other posts, but it did not work for me. I a on linux, I use Android Studio.

My flutter doctor :

[✓] Flutter (Channel master, v1.4.12-pre.27, on Linux, locale en_US.UTF-8) • Flutter version 1.4.12-pre.27 at /home/jeremy/FlutterSDK/flutter • Framework revision a12c5618de (5 hours ago), 2019-04-08 11:22:19 -0400 • Engine revision ff1bcdc009 • Dart version 2.2.1 (build 2.2.1-dev.3.0 None)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at /home/jeremy/Android/Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-28, build-tools 28.0.3 • Java binary at: /home/jeremy/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/182.5314842/jre/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01) • All Android licenses accepted.

[✓] Android Studio (version 3.2) • Android Studio at /opt/android-studio • Flutter plugin version 31.3.1 • Dart plugin version 181.5656 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] Android Studio (version 3.3) • Android Studio at /home/jeremy/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/182.5314842 • Flutter plugin version 34.0.1 • Dart plugin version 182.5215 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] Connected device (1 available) • SM J530F • 52007a75eaa9b403 • android-arm • Android 8.1.0 (API 27)

• No issues found!

Thank's in advance. Jérémy.

1
It says no issue, the ndk is optionalPeter Haddad
Yes, my flutter doctor say no issue, but I've a lot of errors.Jérémy Gachon
What are the errors?Peter Haddad
Oh. Excuse-me. I've post this message without the errors. I've just edit it.Jérémy Gachon
No, I had Firestore in another project, This morning, my other project show this errors. I didn't find the soluce and I create a new project without code. I had correctly imported firebase and my others dependences and I had the same issue. I've searched the soluce during 3 hours after post this message.Jérémy Gachon

1 Answers

3
votes

For solve my issue, I've add :

In the android/app/build.gradle :

android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
        multiDexEnabled true
    }
}

In the android/gradle.properties :

android.useAndroidX=true
android.enableJetifier=true

In the android/build.gradle : `

subprojects {
    project.evaluationDependsOn(':app')
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
        }
    }
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'androidx.core' &&
                    !details.requested.name.contains('androidx')) {
                details.useVersion "1.0.1"
            }
        }
    }
}