【问题标题】:My Flutter app doesnt compile anymore due to cloud firestore and firebase auth errors由于 cloud firestore 和 firebase auth 错误,我的 Flutter 应用程序不再编译
【发布时间】:2021-04-02 12:43:29
【问题描述】:

我花了几天时间尝试使用 Firebase 调试我的应用。 以前它工作得很好,直到上周我更新了很多东西; android studio、flutter、插件等 编译后这始终是我的结果;

import android.support.annotation.NonNull;
                                 ^
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:538: error: cannot find symbol
    public void onComplete(@NonNull Task<AuthResult> task) {
                            ^
  symbol:   class NonNull
  location: class FirebaseAuthPlugin.SignInCompleteListener
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:558: error: cannot find symbol
    public void onComplete(@NonNull Task<Void> task) {
                            ^
  symbol:   class NonNull
  location: class FirebaseAuthPlugin.TaskVoidCompleteListener
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:576: error: cannot find symbol
    public void onComplete(@NonNull Task<ProviderQueryResult> task) {
                            ^
  symbol:   class NonNull
  location: class FirebaseAuthPlugin.ProvidersCompleteListener
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:175: error: cannot find symbol
                      public void onComplete(@NonNull Task<AuthResult> task) {
                                              ^
  symbol: class NonNull
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:270: error: cannot find symbol
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                                          ^
  symbol: class NonNull
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:435: error: cannot find symbol
              public void onComplete(@NonNull Task<GetTokenResult> task) {
                                      ^
  symbol: class NonNull
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:487: error: cannot find symbol
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                                          ^
  symbol: class NonNull
Note: /home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
8 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':firebase_auth: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 2m 48s
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...
Running Gradle task 'assembleAarRelease'...
Exception: The plugin cloud_firestore could not be built due to the issue above.

我尝试了有关 androidX 的不同修复,但我的项目已经迁移并且一直如此,所以似乎没有一个工作。

Flutter Doctor 输出还不错

[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Android Studio
[✓] Connected device (1 available)

• No issues found!```

【问题讨论】:

标签: firebase flutter google-cloud-firestore firebase-authentication androidx


【解决方案1】:

找到解决方案!!

这确实是由 AndroidX 问题引起的,但迁移没有任何帮助。 所以我用来解决它的步骤是;

  1. 打开 android 文件夹以使用 Android Studio 进行编辑。 2.运行 Gradle 同步。 3.运行应用程序。 (这显然会失败!但带您到使用 Android 支持库导入的文件。)

  2. 删除 android support import(import android.support.annotations.NonNull) 并用 AndroidX import 替换它。

    导入 androidx.annotations.NonNull

(我不记得确切的导入语句,但你可以谷歌并得到它)

就是这样,一切顺利!

【讨论】:

    猜你喜欢
    • 2019-08-30
    • 2020-06-08
    • 2021-08-27
    • 2021-06-24
    • 2019-12-05
    • 1970-01-01
    • 2022-08-12
    • 2020-12-24
    • 2021-06-25
    相关资源
    最近更新 更多