0
votes

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
Might want to look into "Migrating to AndroiX".LawfulGood
have you move to android XAvnish kumar

4 Answers

0
votes

Have you migrated your project to AndroidX?

Looks like you haven't migrated your project to AndroidX.


What is AndroidX?

"AndroidX is a major improvement to the original Android Support Library. AndroidX fully replaces the Support Library. All new android projects are requested to be migrated to AndroidX if your project is dependant on libraries using AndroidX"

read more here ...


How to migrate to AndroidX

Summary

[ Prerequisite: Android Studio 3.2+. ]
[ Please take a backup before proceeding.]

  1. Open your android project in Android Studio
  2. Add these two lines to your gradle.properties file
    android.useAndroidX=true
    android.enableJetifier=true

  3. Go to your app level build.gradle file and change your compileSdkVersion and targetSdkVersion to 28

  4. From menu click on Refactor > Migrate to AndroidX

  5. Optionally you can take a zip backup on prompt.

  6. Once the list is prepared, click on 'Do Refactor'

read more here ...

1
votes

I stumbled upon a similar problem, because a firebase plugin used compileSdkVersion 27 - I simply forked it to use 28, but it should also be possible to override it from the project root's build.gradle: https://stackoverflow.com/a/50916298/109219

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
            }
        }
    }
}
0
votes

have you move to android X? if yes,

1)make sure your compileSdkVersion and targetSdkVersion is 28

2)sometimes kotlin version is also a cause of this type of error, make sure you use the latest version of kotlin .(ext.kotlin_version = '1.3.10', in my case).

3)classpath 'com.google.gms:google-services:4.3.2'

4) follow firebase instruction carefully, for adding your application to firebase.

5) if you are using firebase_auth, make sure you enter SHA-1 and SHA-256 signature while adding your application to firebase.

don't forget to consider flutter clean as last step

0
votes

With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

The refactor command makes use of two flags. By default, both of them are set to true in your gradle.properties file:

android.useAndroidX=true

The Android plugin uses the appropriate AndroidX library instead of a Support Library.

android.enableJetifier=true

The Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries.