Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase auth plugin crash IOS and android #27422

Closed
tzvc opened this issue Feb 2, 2019 · 7 comments
Closed

Firebase auth plugin crash IOS and android #27422

tzvc opened this issue Feb 2, 2019 · 7 comments
Labels
c: crash Stack traces logged to the console p: firebase_auth The Firebase Auth plugin

Comments

@tzvc
Copy link

tzvc commented Feb 2, 2019

Hi,

I'm trying to use the Firebase auth plugin for my app, but after installing everything as explained in the firebase docs and running it, it crash on both Android and IOS.

My pubspec.yaml:

dependencies:
  google_sign_in: ^4.0.0
  firebase_auth: ^0.8.0+1

Crash on IOS:

Launching lib/main.dart on iPhone XS Max in debug mode...
Xcode build done.                                            7.3s
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010576329b __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x0000000104cff735 objc_exception_throw + 48
	2   CoreFoundation                      0x00000001057630f5 +[NSException raise:format:] + 197
	3   Runner                              0x00000001019449f0 +[FIRApp configure] + 576
	4   Runner                              0x00000001019a3e3c -[FLTFirebaseAuthPlugin init] + 188
	5   Runner                              0x00000001019a3cad +[FLTFirebaseAuthPlugin registerWithRegistrar:] + 173
	6   Runner                              0x00000001018e9c4b +[GeneratedPluginRegistrant registerWithRegistry:] + 123
	7   Runner                            <…>

Crash on android:


Launching lib/main.dart on ONEPLUS A5010 in debug mode...
Initializing gradle...                                       1.0s
Resolving dependencies...                                    2.3s
Gradle task 'assembleDebug'...
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)
/Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/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
/Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/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
/Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:638: error: cannot find symbol
  private void reportException(Result result, @Nullable Exception exception) {
                                               ^
  symbol:   class Nullable
  location: class FirebaseAuthPlugin
/Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:550: error: cannot find symbol
    public void onComplete(@NonNull Task<AuthResult> task) {
                            ^
  symbol:   class NonNull
  location: class FirebaseAuthPlugin.SignInCompleteListener
/Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:569: error: cannot find symbol
    public void onComplete(@NonNull Task<Void> task) {
                            ^
  symbol:   class NonNull
  location: class FirebaseAuthPlugin.TaskVoidCompleteListener
/Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:587: error: cannot find symbol
    public void onComplete(@NonNull Task<SignInMethodQueryResult> task) {
                            ^
  symbol:   class NonNull
  location: class FirebaseAuthPlugin.GetSignInMethodsCompleteListener
/Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:186: error: cannot find symbol
                      public void onComplete(@NonNull Task<AuthResult> task) {
                                              ^
  symbol: class NonNull
/Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:445: error: cannot find symbol
              public void onComplete(@NonNull Task<GetTokenResult> task) {
                                      ^
  symbol: class NonNull
/Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:499: error: cannot find symbol
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                                          ^
  symbol: class NonNull
Note: /Users/theo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.0+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
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.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s

Gradle task 'assembleDebug'... Done                          5.4s
Gradle task assembleDebug failed with exit code 1

flutter doctor -v

[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale en-AU)
    • Flutter version 1.0.0 at /Users/theo/flutter
    • Framework revision 5391447fae (9 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
@wouterhardeman
Copy link

The Android error is caused by the migration to AndroidX. Check this comment on how to resolve that issue: #27106 (comment)

Have you followed to iOS integration guide from the google_sign_in plugin? https://pub.dartlang.org/packages/google_sign_in

@app-o-matix
Copy link

app-o-matix commented Feb 3, 2019

@theochampion

I was getting these errors as well. See if these steps help. At the moment, I can only confirm that both the iOS and Android versions of my app build successfully. I have not yet had a chance to test how thoroughly they are working properly with Firebase. If anyone with more knowledge than I sees anything that shouldn't be done the way I am suggesting or should be done differently, please let me know. The intent of this is to do good, not harm.

Note: I'm using IntelliJ Idea CE. If you are using VSCode or the command line, you will have to adjust accordingly. Also, I create my Flutter projects with Kotlin and Swift. So, if you are creating yours with Java and/or Objective-C, you may have to make additional adjustments to these instructions.

iOS

First of all, do not add

import Firebase and FirebaseApp.configure()

to your [my_project]/ios/Runner/AppDelegate.swift file as instructed in the Firebase instructions. This will be handled by the Firebase plugins. If you do have those lines of code, either remove them or comment them out.

  1. Make sure you are using the latest version of the plugins in your pubspec.yaml file (I'm also using firebase_core):
dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^0.3.0
  firebase_auth: ^0.8.0+1
  google_sign_in: ^4.0.0
  1. Run Tools > Flutter > Flutter Packages Get (I ran Tools > Flutter > Flutter Clean first).

  2. If your iOS app has not already been added to your Firebase project, add it and download the GoogleService-Info.plist file. I downloaded mine to [my_project]/ios/Runner, although downloading it there does not install it.

Note: I added GoogleService-Info.plist to my [my_project]/.gitignore based upon the answer to the stackoverflow question Firebase: Should I add GoogleService-Info.plist to .gitignore?.

  1. In your Flutter project, open [my_project]/ios/Runner.xcworkspace in Xcode. In IntelliJ Idea, you can do this by right-clicking the Runner.xcworkspace folder and selecting Flutter > Open iOS module in Xcode.

  2. In Xcode, if you downloaded the GoogleService-Info.plist file to [my_project]/ios/Runner, you will likely still not see it in the Runner project subdirectory. Open a macOS finder window, navigate to the GoogleService-Info.plist in your Flutter project (e.g. ~/IdeaProjects/[my_project]/ios/Runner/GoogleService-Info.plist), click it and drag it to the Runner project subdirectory in Xcode (not the parent Runner workspace directory). Xcode will ask you to confirm, so do so. (Alternatively, you can right-click the Runner project subdirectory and select Add Files to "Runner"... The file selector will already be in the Runner subdirectory, so if you saved the GoogleService-Info.plist file there when you downloaded it, all you need to do is select it and add it.)

Note: I made these additional adjustments while in Xcode:

  • File > Workspace Settings...: confirmed Build System was set to Legacy Build System
  • Selected Runner at top of left panel, then Build Settings at top of center panel, entered "Swift" into search box, then set Swift 3 @objc Inference to "Default" (applied to all 3 - Debug, Profile, Release)
  • Still in Build Settings, entered "iOS" in search box, then set iOS Deployment Target to "12.1"
  • In right hand panel, under Project Document, set Project Format to "Xcode 10.0-compatible"
  • Clicked on gold warnings triangle at the top of the center panel, then in the left hand panel on Update to recommended settings and updated to recommended settings.

  1. Quit Xcode.

  2. Back in IntelliJ Idea, per the google_sign_in plugin instructions, add the following lines of code to the [my_project]/ios/Runner/Info.plist file:

<!-- Google Sign-in Section -->
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <!-- TODO Replace this value: -->
      <!-- Copied from GoogleServices-Info.plist key REVERSED_CLIENT_ID -->
      <string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
    </array>
  </dict>
</array>
<!-- End of the Google Sign-in Section -->

I don't know that it matters exactly where amongst the keys in the file you put it. I placed it between these two lines:

<key>LSRequiresIPhoneOS</key>
<true/>
<!-- Google Sign-in Section -->
  .
  .
  .
<!-- End of the Google Sign-in Section -->
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
  1. Open your [my_project]/ios/Runner/GoogleService-Info.plist file, copy the REVERSED_CLIENT_ID string, and paste it into the code you just added to the Info.plist file in the previous step, replacing the sample REVERSED_CLIENT_ID string provided (as indicated in the TODO code comment). Save.

  2. If you don't yet have a Podfile in your [my_project]/ios subdirectory, open the terminal, cd to the [my_project]/ios subdirectory, then run pod init. After this, if, in Step 5 above, you changed the iOS Deployment Target setting in Xcode (see "Note" after Step 5), open your Podfile, uncomment the platform :ios line at the top, and change the iOS version to match your setting in Xcode (e.g. platform :ios, '12.1').

Note: If, like me, you are using the firebase_core plugin, you will need to include pod 'Firebase/Core' in your [my_project]/ios/Podfile file, here:

target 'Runner' do
  use_frameworks!
  pod 'Firebase/Core'

and add #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig" to [my_project]/ios/Flutter/Release.xconfig

  1. In the terminal, in the [my_project]/ios subdirectory, run pod install. (Before this, I may have run Tools > Flutter > Flutter Clean, then File > Save All, then File > Invalidate Caches/Restart..., then after restart Tools > Flutter > Flutter Packages Get just to make sure everything was clean).

After these steps (I don't believe I've left anything out), I opened the iOS Simulator (I'm using iPhone XS Max - 12.1) and ran the app and it built successfully. 😃

Note: If I build in Xcode rather than in IntelliJ Idea, I get a number of warnings. All of these warnings, however, are related to code in the plugins. So, I'm not sure there is anything for me to do to address them.

Android

  1. Open the Android portion of your Flutter project in Android Studio. Make sure you are using Android Studio 3.3. (I closed IntelliJ Idea altogether, opened Android Studio, clicked on File > Open, and navigated to the ~/IdeaProjects/[my_project]/android folder in my Flutter project. Upon opening the Android project followed by Android Studio starting to sync it, a message/pop-up appeared asking if it could update the Gradle plugin, so I let it. It was upgraded to version 3.3.0.)

  2. Add the following 2 lines to the bottom of the [my_project]/android/gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

Note: I'm not sure if android.enableJetifier=true could have been, or should have been, set to false. Perhaps someone else can clarify under which conditions it should be true vs false. I believe it has something to do with whether or not the project has additional libraries that haven't yet been migrated to AndroidX, but, if my belief is correct, I don't know if when this setting is set to true it means Android Studio will migrate these libraries to AndroidX or that it will make code adjustments to account for the fact that the libraries aren't yet AndroidX compatible. Or maybe I'm totally wrong and it is something else altogether.

  1. In the Android Studio main menus, select Refactor > Migrate to Androidx..., saving a backup of your project to a .zip file. Follow this with File > Save All and then quit Android Studio.

  2. If your Android app has not already been added to your Firebase project, add it and download the google-services.json file either directly to the ~/IdeaProjects/[my_project]/android/app subdirectory or elsewhere (e.g. ~/Downloads) and then drag it there in the Finder.

Note: google-services.json was already an entry in my [my_project]/.gitignore file. If it is not in yours, you may want to add it, based upon the answer to the stackoverflow question Firebase: Should I add GoogleService-Info.plist to .gitignore?, since it would seem to apply to this file as well.

  1. Reopen your Flutter project in IntelliJ Idea and update your Kotlin plugin to version 1.3.20, if it has not been previously updated. This is done with IntelliJ IDEA > Preferences > Languages & Frameworks > Kotlin. With Update Channel set to Stable, if a message indicating an updated version is not already visible, clicking the Check again button will reveal if there is an update to the plugin. If you are not currently using 1.3.20, then update to it.

  2. In the [my_project]/android/build.gradle file, change the Kotlin version to match the updated plugin version (the release suffix on the plugin version, e.g. -release-IJ2018.3-1, is not needed):

buildscript {
    ext.kotlin_version = '1.3.20'
	.
	.
	.

Note: Since there are two build.gradle files in the Android version of your app, [my_project]/android/build.gradle and [my_project]/android/app/build.gradle, ensure that you are make code changes to the correct file. This advice may be obvious, but I thought it couldn't hurt to emphasize it.

  1. In your [my_project]/android/app/build.gradle file, make the following changes:
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
}

These were code analysis suggestions by IntelliJ Idea. The change in the implementation line to jdk is subtle and perhaps possible to miss.

Change these lines in the [my_project]/android/app/build.gradle file as well (although I don't recall the specific source(s) that recommended them).

android {
    compileSdkVersion 28
    .
    .
    .
    defaultConfig {
        .
        .
        .
        minSdkVersion 21
        targetSdkVersion 28

Either before or after the next step, a pop-up in IntelliJ Idea informed me Kotlin migrations to the new version could be run, so I chose to let it do so.

  1. Per the firebase_auth plugin instructions, add/change the following lines of code in the [my_project]/android/build.gradle file, although I updated the com.android.tools.build:gradle version to 3.3.0 rather than keeping it 3.2.1 as in the instructions (see the last sentence in Step 1 above)) :
dependencies {
  // Example existing classpath
  classpath 'com.android.tools.build:gradle:3.3.0'
  // Existing classpath, unchanged
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  // Add the google services classpath
  classpath 'com.google.gms:google-services:4.2.0'
}
  1. Also per the firebase_auth plugin instructions, add the following line of code to the bottom of the [my_project]/android/app/build.gradle file:
apply plugin: 'com.google.gms.google-services'

Note: After Step 9, I ran Tools > Flutter > Flutter Clean, then File > Save All, then File > Invalidate Caches/Restart..., then after restart Tools > Flutter > Flutter Packages Get just to make sure everything was clean.

After these steps (once again, I don't think I've left anything out), I opened the Android Emulator (I'm using the Nexus 5X API 28 because it supports Google Play, which I believe is necessary for Firebase) and ran the app and it built successfully. 😃

Hope this helps. Cheers!

UPDATE (03-04-19): See one additional step for Android in my follow up comment below.

@app-o-matix
Copy link

Even though the Android app was building and connecting to Firebase, I was briefly seeing the
"ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}'" error, so I added these lines

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

to the [my_project]/android/app/build.gradle file here:

android {
    compileSdkVersion 28

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
.
.
.

as suggested in Dhaval Patel's answer to the stackoverflow question Failed to resolve variable '${animal.sniffer.version}' when migrate to AndroidX and this appears to have resolved it.

@GaryQian GaryQian added c: crash Stack traces logged to the console p: firebase_auth The Firebase Auth plugin labels Feb 6, 2019
@zoechi
Copy link
Contributor

zoechi commented Feb 7, 2019

import androidx.annotation.NonNull;

This looks like #27106

@kroikie
Copy link

kroikie commented Oct 13, 2019

@theochampion

This issue has been moved to firebase/flutterfire#1117. Any further collaboration will be done there.

@CoderJava
Copy link

@theochampion

I was getting these errors as well. See if these steps help. At the moment, I can only confirm that both the iOS and Android versions of my app build successfully. I have not yet had a chance to test how thoroughly they are working properly with Firebase. If anyone with more knowledge than I sees anything that shouldn't be done the way I am suggesting or should be done differently, please let me know. The intent of this is to do good, not harm.

Note: I'm using IntelliJ Idea CE. If you are using VSCode or the command line, you will have to adjust accordingly. Also, I create my Flutter projects with Kotlin and Swift. So, if you are creating yours with Java and/or Objective-C, you may have to make additional adjustments to these instructions.

iOS

First of all, do not add

import Firebase and FirebaseApp.configure()

to your [my_project]/ios/Runner/AppDelegate.swift file as instructed in the Firebase instructions. This will be handled by the Firebase plugins. If you do have those lines of code, either remove them or comment them out.

  1. Make sure you are using the latest version of the plugins in your pubspec.yaml file (I'm also using firebase_core):
dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^0.3.0
  firebase_auth: ^0.8.0+1
  google_sign_in: ^4.0.0
  1. Run Tools > Flutter > Flutter Packages Get (I ran Tools > Flutter > Flutter Clean first).
  2. If your iOS app has not already been added to your Firebase project, add it and download the GoogleService-Info.plist file. I downloaded mine to [my_project]/ios/Runner, although downloading it there does not install it.

Note: I added GoogleService-Info.plist to my [my_project]/.gitignore based upon the answer to the stackoverflow question Firebase: Should I add GoogleService-Info.plist to .gitignore?.

  1. In your Flutter project, open [my_project]/ios/Runner.xcworkspace in Xcode. In IntelliJ Idea, you can do this by right-clicking the Runner.xcworkspace folder and selecting Flutter > Open iOS module in Xcode.
  2. In Xcode, if you downloaded the GoogleService-Info.plist file to [my_project]/ios/Runner, you will likely still not see it in the Runner project subdirectory. Open a macOS finder window, navigate to the GoogleService-Info.plist in your Flutter project (e.g. ~/IdeaProjects/[my_project]/ios/Runner/GoogleService-Info.plist), click it and drag it to the Runner project subdirectory in Xcode (not the parent Runner workspace directory). Xcode will ask you to confirm, so do so. (Alternatively, you can right-click the Runner project subdirectory and select Add Files to "Runner"... The file selector will already be in the Runner subdirectory, so if you saved the GoogleService-Info.plist file there when you downloaded it, all you need to do is select it and add it.)

Note: I made these additional adjustments while in Xcode: * File > Workspace Settings...: confirmed Build System was set to Legacy Build System* Selected Runner at top of left panel, then Build Settings at top of center panel, entered "Swift" into search box, then set Swift 3 @objc Inference to "Default" (applied to all 3 - Debug, Profile, Release)* Still in Build Settings, entered "iOS" in search box, then set iOS Deployment Target to "12.1"* In right hand panel, under Project Document, set Project Format to "Xcode 10.0-compatible"* Clicked on gold warnings triangle at the top of the center panel, then in the left hand panel on Update to recommended settings and updated to recommended settings.

  1. Quit Xcode.
  2. Back in IntelliJ Idea, per the google_sign_in plugin instructions, add the following lines of code to the [my_project]/ios/Runner/Info.plist file:
<!-- Google Sign-in Section -->
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <!-- TODO Replace this value: -->
      <!-- Copied from GoogleServices-Info.plist key REVERSED_CLIENT_ID -->
      <string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
    </array>
  </dict>
</array>
<!-- End of the Google Sign-in Section -->

I don't know that it matters exactly where amongst the keys in the file you put it. I placed it between these two lines:

<key>LSRequiresIPhoneOS</key>
<true/>
<!-- Google Sign-in Section -->
  .
  .
  .
<!-- End of the Google Sign-in Section -->
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
  1. Open your [my_project]/ios/Runner/GoogleService-Info.plist file, copy the REVERSED_CLIENT_ID string, and paste it into the code you just added to the Info.plist file in the previous step, replacing the sample REVERSED_CLIENT_ID string provided (as indicated in the TODO code comment). Save.
  2. If you don't yet have a Podfile in your [my_project]/ios subdirectory, open the terminal, cd to the [my_project]/ios subdirectory, then run pod init. After this, if, in Step 5 above, you changed the iOS Deployment Target setting in Xcode (see "Note" after Step 5), open your Podfile, uncomment the platform :ios line at the top, and change the iOS version to match your setting in Xcode (e.g. platform :ios, '12.1').

Note: If, like me, you are using the firebase_core plugin, you will need to include pod 'Firebase/Core' in your [my_project]/ios/Podfile file, here:

target 'Runner' do
  use_frameworks!
  pod 'Firebase/Core'

and add #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig" to [my_project]/ios/Flutter/Release.xconfig

  1. In the terminal, in the [my_project]/ios subdirectory, run pod install. (Before this, I may have run Tools > Flutter > Flutter Clean, then File > Save All, then File > Invalidate Caches/Restart..., then after restart Tools > Flutter > Flutter Packages Get just to make sure everything was clean).

After these steps (I don't believe I've left anything out), I opened the iOS Simulator (I'm using iPhone XS Max - 12.1) and ran the app and it built successfully. 😃

Note: If I build in Xcode rather than in IntelliJ Idea, I get a number of warnings. All of these warnings, however, are related to code in the plugins. So, I'm not sure there is anything for me to do to address them.

Android

  1. Open the Android portion of your Flutter project in Android Studio. Make sure you are using Android Studio 3.3. (I closed IntelliJ Idea altogether, opened Android Studio, clicked on File > Open, and navigated to the ~/IdeaProjects/[my_project]/android folder in my Flutter project. Upon opening the Android project followed by Android Studio starting to sync it, a message/pop-up appeared asking if it could update the Gradle plugin, so I let it. It was upgraded to version 3.3.0.)
  2. Add the following 2 lines to the bottom of the [my_project]/android/gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true

Note: I'm not sure if android.enableJetifier=true could have been, or should have been, set to false. Perhaps someone else can clarify under which conditions it should be true vs false. I believe it has something to do with whether or not the project has additional libraries that haven't yet been migrated to AndroidX, but, if my belief is correct, I don't know if when this setting is set to true it means Android Studio will migrate these libraries to AndroidX or that it will make code adjustments to account for the fact that the libraries aren't yet AndroidX compatible. Or maybe I'm totally wrong and it is something else altogether.

  1. In the Android Studio main menus, select Refactor > Migrate to Androidx..., saving a backup of your project to a .zip file. Follow this with File > Save All and then quit Android Studio.
  2. If your Android app has not already been added to your Firebase project, add it and download the google-services.json file either directly to the ~/IdeaProjects/[my_project]/android/app subdirectory or elsewhere (e.g. ~/Downloads) and then drag it there in the Finder.

Note: google-services.json was already an entry in my [my_project]/.gitignore file. If it is not in yours, you may want to add it, based upon the answer to the stackoverflow question Firebase: Should I add GoogleService-Info.plist to .gitignore?, since it would seem to apply to this file as well.

  1. Reopen your Flutter project in IntelliJ Idea and update your Kotlin plugin to version 1.3.20, if it has not been previously updated. This is done with IntelliJ IDEA > Preferences > Languages & Frameworks > Kotlin. With Update Channel set to Stable, if a message indicating an updated version is not already visible, clicking the Check again button will reveal if there is an update to the plugin. If you are not currently using 1.3.20, then update to it.
  2. In the [my_project]/android/build.gradle file, change the Kotlin version to match the updated plugin version (the release suffix on the plugin version, e.g. -release-IJ2018.3-1, is not needed):
buildscript {
    ext.kotlin_version = '1.3.20'
	.
	.
	.

Note: Since there are two build.gradle files in the Android version of your app, [my_project]/android/build.gradle and [my_project]/android/app/build.gradle, ensure that you are make code changes to the correct file. This advice may be obvious, but I thought it couldn't hurt to emphasize it.

  1. In your [my_project]/android/app/build.gradle file, make the following changes:
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
}

These were code analysis suggestions by IntelliJ Idea. The change in the implementation line to jdk is subtle and perhaps possible to miss.

Change these lines in the [my_project]/android/app/build.gradle file as well (although I don't recall the specific source(s) that recommended them).

android {
    compileSdkVersion 28
    .
    .
    .
    defaultConfig {
        .
        .
        .
        minSdkVersion 21
        targetSdkVersion 28

Either before or after the next step, a pop-up in IntelliJ Idea informed me Kotlin migrations to the new version could be run, so I chose to let it do so.

  1. Per the firebase_auth plugin instructions, add/change the following lines of code in the [my_project]/android/build.gradle file, although I updated the com.android.tools.build:gradle version to 3.3.0 rather than keeping it 3.2.1 as in the instructions (see the last sentence in Step 1 above)) :
dependencies {
  // Example existing classpath
  classpath 'com.android.tools.build:gradle:3.3.0'
  // Existing classpath, unchanged
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  // Add the google services classpath
  classpath 'com.google.gms:google-services:4.2.0'
}
  1. Also per the firebase_auth plugin instructions, add the following line of code to the bottom of the [my_project]/android/app/build.gradle file:
apply plugin: 'com.google.gms.google-services'

Note: After Step 9, I ran Tools > Flutter > Flutter Clean, then File > Save All, then File > Invalidate Caches/Restart..., then after restart Tools > Flutter > Flutter Packages Get just to make sure everything was clean.

After these steps (once again, I don't think I've left anything out), I opened the Android Emulator (I'm using the Nexus 5X API 28 because it supports Google Play, which I believe is necessary for Firebase) and ran the app and it built successfully. 😃

Hope this helps. Cheers!

UPDATE (03-04-19): See one additional step for Android in my follow up comment below.

Thank you. It's work...

@lock
Copy link

lock bot commented Apr 18, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock lock bot locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console p: firebase_auth The Firebase Auth plugin
Projects
None yet
Development

No branches or pull requests

7 participants