0

Ran into build errors, migrated to android X, Changed the plugins .....................................

Running "flutter packages get" in prototype...                   1.4s Launching lib\main.dart on Redmi 5 Plus in debug mode... 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:\Users\kenny\Documents\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.1+4\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:\Users\kenny\Documents\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.1+4\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:\Users\kenny\Documents\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.1+4\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:706: error: cannot find symbol   private void reportException(Result result, @Nullable Exception exception) {                                                ^   symbol:   class Nullable   location: class FirebaseAuthPlugin C:\Users\kenny\Documents\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.1+4\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:610: error: cannot find symbol     public void onComplete(@NonNull Task task) {                             ^   symbol:   class NonNull   location: class FirebaseAuthPlugin.SignInCompleteListener C:\Users\kenny\Documents\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.1+4\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:629: error: cannot find symbol     public void onComplete(@NonNull Task task) {                             ^   symbol:   class NonNull   location: class FirebaseAuthPlugin.TaskVoidCompleteListener C:\Users\kenny\Documents\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.1+4\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:647: error: cannot find symbol     public void onComplete(@NonNull Task task) {                             ^   symbol:   class NonNull   location: class FirebaseAuthPlugin.GetSignInMethodsCompleteListener C:\Users\kenny\Documents\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.1+4\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:187: error: cannot find symbol                       public void onComplete(@NonNull Task task) {                                               ^   symbol: class NonNull C:\Users\kenny\Documents\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.1+4\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:492: error: cannot find symbol               public void onComplete(@NonNull Task task) {                                       ^   symbol: class NonNull C:\Users\kenny\Documents\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.1+4\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:559: error: cannot find symbol           public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {                                           ^   symbol: class NonNull 9 errors          ********************************************************* WARNING: This version of cloud_firestore will break your Android build if it or its dependencies aren't compatible with AndroidX.          See .... for more information on the problem and how to fix it.          This warning prints for all Android build failures. The real root cause of the error may be unrelated.          *********************************************************

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 10s Gradle task assembleDebug failed with exit code 1 Exited (sigterm)

4

4 回答 4

1

我偶然发现了一个类似的问题,因为使用了一个 firebase 插件compileSdkVersion 27- 我只是将它分叉使用28,但也应该可以从项目根目录中覆盖它build.gradlehttps ://stackoverflow.com/a/50916298/109219

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
            }
        }
    }
}
于 2019-03-04T23:27:26.367 回答
0

在 Android Studio 3.2 及更高版本中,您可以通过从菜单栏中选择 Refactor > Migrate to AndroidX 将现有项目迁移到 AndroidX。

重构命令使用两个标志。默认情况下,它们在您的gradle.properties文件中都设置为 true:

android.useAndroidX=true

Android 插件使用适当的 AndroidX 库而不是支持库。

android.enableJetifier=true

Android 插件通过重写其二进制文件自动迁移现有的第三方库以使用 AndroidX。

于 2020-09-09T18:35:21.013 回答
0

你搬到android X了吗?如果是,

1)确保您的 compileSdkVersion 和 targetSdkVersion 为 28

2)有时 kotlin 版本也是导致此类错误的原因,请确保使用最新版本的 kotlin 。(在我的情况下,ext.kotlin_version = '1.3.10')。

3)类路径'com.google.gms:google-services:4.3.2'

4)仔细遵循firebase指令,将您的应用程序添加到firebase。

5) 如果您使用的是 firebase_auth,请确保在将应用程序添加到 firebase 时输入 SHA-1 和 SHA-256 签名。

不要忘记将 Flutter clean 作为最后一步

于 2019-10-29T16:29:16.173 回答
0

您是否已将项目迁移到 AndroidX?

看起来您还没有将项目迁移到 AndroidX。


什么是安卓X?

“AndroidX 是对原始 Android Support Library 的重大改进。AndroidX 完全取代了 Support Library。如果您的项目依赖于使用 AndroidX 的库,则要求所有新的 android 项目迁移到 AndroidX”

在这里阅读更多...


如何迁移到 AndroidX

概括

[先决条件:Android Studio 3.2+。]
[请在继续之前进行备份。]

  1. 在 Android Studio 中打开你的 android 项目
  2. 将这两行添加到您的gradle.properties文件
    android.useAndroidX=true
    android.enableJetifier=true

  3. 转到您的应用级别build.gradle文件并将您的 compileSdkVersiontargetSdkVersion更改为28

  4. 从菜单中点击Refactor > Migrate to AndroidX

  5. 或者,您可以在提示时进行 zip 备份。

  6. 准备好列表后,单击“进行重构

在这里阅读更多...

于 2019-03-05T03:51:45.770 回答