当前位置: 首页 > 知识库问答 >
问题:

Firebase Cloud Firestore生成编译错误

李振国
2023-03-14
/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
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
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
}
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.

[]Flutter(Channel master,v1.4.12-pre.27,on Linux,locale en_us.utf-8)•Flutter版本1.4.12-pre.27 at/home/jeremy/fluttersdk/Flutter•Framework修订版a12c5618de(5小时前),2019-04-08 11:22:19-0400•Engine修订版ff1bcdc009•Dart版本2.2.1(build 2.2.1-dev.3.0 None)

[]Android toolchain-为Android设备开发(Android SDK版本28.0.3)•Android SDK位于/Home/Jeremy/Android/SDK•未配置Android NDK位置(可选;用于本机分析支持)•平台android-28,build-tools 28.0.3•Java二进制地址:/Home/Jeremy/.local/Share/JetBrains/Toolbox/Apps/AndroidStudio/CH-0/182.514842/JRE/bin/Java•Java版本OpenJDK运行时环境(build 1.8.0_152-Release-1248-B01)•接受所有Android许可。

[]Android Studio(版本3.2)•Android Studio at/opt/android-studio•Flutter插件版本31.3.1•Dart插件版本181.5656•Java版本OpenJDK运行时环境(构建版本1.8.0_152-Release-1248-B01)

[]Android Studio(版本3.3)•Android Studio at/home/jeremy/.local/share/jetbrains/toolbox/apps/AndroidStudio/ch-0/182.5314842•Flutter插件版本34.0.1•Dart插件版本182.5215•Java版本OpenJDK运行时环境(版本1.8.0_152-Release-1248-B01)

[]连接设备(1个可用)•SM J530F•52007A75EAA9B403•android-arm•Android 8.1.0(API 27)

•未发现任何问题!

事先谢谢。热雷米。

共有1个答案

武峻熙
2023-03-14

为了解决我问题,我补充:

在Android/app/build.gradle中:

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

在android/gradle.properties中:

android.useAndroidX=true
android.enableJetifier=true
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"
            }
        }
    }
}
 类似资料:
  • 我创建了一个简单的. proto文件并执行了编译器(protoc-2.5.0rc1-win32.zip)。为规定的包生成了一个java文件。但是,生成的文件不会编译。. proto文件很简单,只有一条消息,其中包含一堆简单类型的可选字段(正确编号)。. java文件不编译,例如: 构造函数生成了消息。FieldAccessorTable(Descriptors.Descriptor,字符串[])未

  • 我试图从protobuf生成java类。 下面是我的协议- 我运行命令main/exec/protoc--java\u out=main/java main/proto/datamodel。协议 该协议是从链接https://github.com/protocolbuffers/protobuf/releases/tag/v3.7.1下载的,osx-x86_64.zip.我也尝试了3.8.0和3.

  • 我们试图从Jenkins构建一个maven工件并将其部署到我们的Nexus存储库管理器中,但是我们在构建过程中遇到了编译错误。这就是我们得到的错误! 错误]无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:在项目上编译(default-compile)studentapp:编译失败错误]此环境中没有提供编译器。您可能是在JRE上运

  • 我正在尝试创建一个自定义注释,例如,确保字段或方法既是又是,如果字段或方法既不是又不是,则会生成编译时错误,如以下示例所示: 到目前为止,我已经完成了两个自定义注释接口: 和: 正如所暗示的,我不知道如何生成编译时错误。Processor的文档清楚地表明我不应该抛出异常, 如果处理器抛出未捕获的异常,该工具可能会停止其他活动注释处理器。 它接着描述了当提出错误条件时会发生什么,现在是如何提出错误条

  • 问题内容: 我正在尝试创建一个自定义批注,例如,以确保字段或方法为and ,并且如果该字段或​​方法不为and ,则将生成编译时错误,如以下示例所示: 到目前为止,我已经完成了两个自定义注释接口: 和: 如所示,我不知道如何生成编译时错误。Processor 的文档清楚地表明,我不应该抛出异常, 如果处理器抛出未捕获的异常,则该工具可能会停止其他活动的注释处理器。 它继续描述了引发错误条件时会发生

  • 我正在 https://github.com/oracle/visualvm 构建这个项目。我的系统中有 JDK10。我将 build xml 中的源和目标选项从 1.5 更改为 1.8,因为有错误说 1.5 不再受支持。现在,我收到一个编译错误,指向common.xml它位于其他子文件夹中。 我不知道是怎么回事,因为错误日志也很模糊。此外,我第一次与Ant合作。 这是日志。 引发错误的通用部分.