Flutter:cloud_firestore的构建错误:版本“ 0.7.4”以上 [英] Flutter: Build errors for cloud_firestore: above version "0.7.4"

查看:140
本文介绍了Flutter:cloud_firestore的构建错误:版本“ 0.7.4”以上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试解决了几个小时的构建问题,直到我意识到这是由于Flutter插件cloud_firestore引起的。 0.7.4版适用于Android和iOS,但0.7.4以上的任何版本(如0.8.2 + 1)都会出现以下错误:

I have been trying to resolve a build issue for hours until I realise it is due to Flutter plugin cloud_firestore. Version 0.7.4 builds fine for both Android and iOS but anything above 0.7.4 like 0.8.2+1 will have errors such as:


CloudFirestorePlugin.java:160:错误:找不到符号
query = query.whereArrayContains(fieldName,value);
^符号:方法whereArrayContains(String,Object)位置:类型为
的变量查询
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8 .2 + 1 / android / src / main / java / io / flutter / plugins / firebase / cloudfirestore / CloudFirestorePlugin.java:598:
错误:找不到符号
builder.setTimestampsInSnapshotsEnabled(
^符号:方法setTimestampsInSnapshotsEnabled(布尔)位置:类型为Builder
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android的变量生成器
/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:678:
错误:找不到符号
返回FieldValue.arrayUnion(toArray(readValue(buffer)));
^符号:方法arrayUnion(Object [])位置:类FieldValue
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+ 1 / android / src / main / java / io / flutter / plugins / firebase / cloudfirestore / CloudFirestorePlugin.java:680:
错误:找不到符号
返回FieldValue.arrayRemove(toArray(readArray(readValue(buffer)) ));
^符号:方法arrayRemove(Object [])位置:类FieldValue注意:
/Users/peterlumdev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+ 1 / android / src / main / java / io / flutter / plugins / firebase / cloudfirestore / CloudFirestorePlugin.java
使用未经检查或不安全的操作。注意:使用
-Xlint:unchecked重新编译以获取详细信息。 4个错误失败:构建失败,并发生异常。
*出了什么问题:任务':cloud_firestore:compileDebugJavaWithJavac'的执行失败。

CloudFirestorePlugin.java:160: error: cannot find symbol query = query.whereArrayContains(fieldName, value); ^ symbol: method whereArrayContains(String,Object) location: variable query of type Query /dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:598: error: cannot find symbol builder.setTimestampsInSnapshotsEnabled( ^ symbol: method setTimestampsInSnapshotsEnabled(Boolean) location: variable builder of type Builder /dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:678: error: cannot find symbol return FieldValue.arrayUnion(toArray(readValue(buffer))); ^ symbol: method arrayUnion(Object[]) location: class FieldValue /dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:680: error: cannot find symbol return FieldValue.arrayRemove(toArray(readValue(buffer))); ^ symbol: method arrayRemove(Object[]) location: class FieldValue Note: /Users/peterlumdev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/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'.


编译失败;有关详细信息,请参见编译器错误输出。
*尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。与--scan一起运行以获取完整的见解。
*在 https://help.gradle.org 上获得更多帮助11s Gradle任务组装失败失败,退出代码为1

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 11s Gradle task assembleDebug failed with exit code 1


我想为两个ios使用0.8.2 + 1 cloud_firestore和Android,因为

I would like to use 0.8.2+1 cloud_firestore for both ios and Android because of the support of

await db.settings(timestampsInSnapshotsEnabled: true);

在这里感谢一些帮助。非常感谢!

Appreciate some help here. Many Thanks!

推荐答案

我觉得你,我也花了很多小时试图解决这个问题。

I feel you, I've also spent hours and hours trying to figure this out.

构建SSCCE,然后将该项目的设置应用于我的项目,然后进行一些调整,我的项目就可以正常工作。

After building a SSCCE, and then applying the settings of that project to my project, and then some tweaking, I got my project working.

尽管我调整的设置超出了我的记忆力,但这些设置似乎影响最大:

Although I adjusted more settings than I care to remember, these seem to have had the highest impact:

pubspec.yaml

# included two other common libraries others might use
cloud_firestore: 0.8.2+1
firebase_auth: 0.7.0
google_sign_in: 3.2.4

明确禁用 android / gradle.properties 中的这两个功能:

Explicitly disable these two features in android/gradle.properties :

android.useAndroidX=false
android.enableJetifier=false

在<$ c $中使用这些版本的依赖项c> android / build.grade :

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.2.0'
}

最后,在 android / app / build.gradle 中使用以下设置:

And finally, use these settings in android/app/build.gradle:

android {
    compileSdkVersion 27
    ...
    defaultConfig {
        ...
        minSdkVersion 21
        targetSdkVersion 28
        multiDexEnabled true
        ...
    }
    ...
}
...
dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.1'
    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'
    compile 'com.android.support:multidex:1.0.3'
}

还值得注意的是,我下载了 google-services.json 再次文件(尽管仅对b无效)本身)。

It's also worth noting that I downloaded the google-services.json file again (though that didn't have any effect just by itself).

这些设置的任何组合都可能对您有所帮助。

Any combination of these settings might help you.

这篇关于Flutter:cloud_firestore的构建错误:版本“ 0.7.4”以上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆