我正在使用Flutter和Firebase设置我的第一个移动应用程序。我最近从使用firebase_auth的登录和注册模块开始。尽管我确信我已经很好地遵循了说明,但是在firebase方面我仍然遇到同样的问题。
我尝试将GradleWrapper更新到最新版本:5.4-all和kotlin版本1.3.30。我删除了我的应用程序的几个较早版本,并多次收回了所有步骤,但似乎找不到自己的解决方案。
我按照错误消息提示我认为可能是问题所在。 android / src / main / java / io.flutter.plugins / GeneratedPluginRegistrant.java
package io.flutter.plugins;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugins.firebaseauth.FirebaseAuthPlugin;
import io.flutter.plugins.firebase.core.FirebaseCorePlugin;
/**
* Generated file. Do not edit.
*/
public final class GeneratedPluginRegistrant {
public static void registerWith(PluginRegistry registry) {
if (alreadyRegisteredWith(registry)) {
return;
}
FirebaseAuthPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebaseauth.FirebaseAuthPlugin"));
FirebaseCorePlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebase.core.FirebaseCorePlugin"));
}
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
final String key = GeneratedPluginRegistrant.class.getCanonicalName();
if (registry.hasPlugin(key)) {
return true;
}
registry.registrarFor(key);
return false;
}
}
两个firebase插件符号均无法解析。
C:\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17763.437], locale en-US)
• Flutter version 1.2.1 at C:\flutter
• Framework revision 8661d8aecd (10 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:/Users/----/AppData/Local/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = C:/Users/---/AppData/Local/Android/Sdk
• Java binary at: C:\Program Files\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android Studio
• Flutter plugin version 34.0.2
• Dart plugin version 183.5901
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[√] VS Code (version 1.33.0)
• VS Code at C:\Users\----\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 2.25.0
[√] Connected device (1 available)
• HTC 10 • FA726BN00007 • android-arm64 • Android 8.0.0 (API 26)
• No issues found!
Process finished with exit code 0
错误消息
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.4+5\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:9: error: cannot find symbol
import androidx.annotation.NonNull;
^
symbol: class NonNull
location: package androidx.annotation
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.4+5\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:10: error: cannot find symbol
import androidx.annotation.Nullable;
^
symbol: class Nullable
location: package androidx.annotation
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.4+5\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:754: error: cannot find symbol
private void reportException(Result result, @Nullable Exception exception) {
^
symbol: class Nullable
location: class FirebaseAuthPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.4+5\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:658: error: cannot find symbol
public void onComplete(@NonNull Task<AuthResult> task) {
^
symbol: class NonNull
location: class FirebaseAuthPlugin.SignInCompleteListener
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.4+5\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:677: error: cannot find symbol
public void onComplete(@NonNull Task<Void> task) {
^
symbol: class NonNull
location: class FirebaseAuthPlugin.TaskVoidCompleteListener
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.4+5\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:695: error: cannot find symbol
public void onComplete(@NonNull Task<SignInMethodQueryResult> task) {
^
symbol: class NonNull
location: class FirebaseAuthPlugin.GetSignInMethodsCompleteListener
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.4+5\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:197: error: cannot find symbol
public void onComplete(@NonNull Task<AuthResult> task) {
^
symbol: class NonNull
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.4+5\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:540: error: cannot find symbol
public void onComplete(@NonNull Task<GetTokenResult> task) {
^
symbol: class NonNull
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.4+5\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:607: error: cannot find symbol
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
^
symbol: class NonNull
9 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.
BUILD FAILED in 6s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
答案 0 :(得分:0)
好像您没有在项目中启用AndroidX。转到gradle-properties(yourApp / android / gradle.properties)并插入以下内容:
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true