fidelisa / flutter_plugins

Flutter plugins
MIT License
35 stars 56 forks source link

Getting started with your flutter_firebase_ui plugin, Android app stops working on startup #13

Open tbaggett opened 6 years ago

tbaggett commented 6 years ago

Hi, thanks for sharing your plugin. I'm having difficulty getting it to work. My app immediately stops working on my Android device when I launch it. However, I was able to download, build and launch your example app on the same Android device without any problems.

I am new to Flutter, so I'm probably doing something wrong. I tried for a couple of hours to get your plugin to work in my app without success, so any suggestions are greatly appreciated.

I was already using the firebase_auth plugin and was able to log in using Google with their example code copied into my main.dart file. This leads me to think I have FireBase Auth set up in my app correctly.

I removed the firebase_auth and google_sign_in dependencies and added a dependency for your plugin in my pubspec.yaml file, and copied your example code into my main.dart file.

Before:

dependencies:
  flutter:
    sdk: flutter
  google_sign_in: ^3.0.4
  firebase_auth: ^0.5.15

After:

dependencies:
  flutter:
    sdk: flutter
  flutter_firebase_ui: ^0.0.8

The only difference I've found is in my google-services.json file. My oauth_client section looks like this (note the client_type value of 1 and android_info subsection):

      "oauth_client": [
        {
          "client_id": "xxxxxxxxxxxxx.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "com.xxxxxxxxx.xxxxxxxxxx",
            "certificate_hash": "xxxxxxxxxxxxxxxx"
          }
        },

In your example app's google-services.json file, your oauth_client section has a client_type value of 3 and is missing the android_info:

      "oauth_client": [
        {
          "client_id": "417099856437-4im65rk0ch0f9u9d5iajrkivi93fu8o9.apps.googleusercontent.com",
          "client_type": 3
        }
      ],

Do you know if the different client type value is causing my issue? Any suggestions on how to fix this? Thanks again.

sbadisa commented 6 years ago

Have you resolved this? Perhaps try adding the google_sign_in and firebase_auth packages back in, as they're dependencies?

adrianmoneta commented 6 years ago

I had the same problem and I solved it by setting up Facebook correctly - adding fb app id into manifest. Whats interesting - this happened even if I removed facebook provider type. I use visual code for development and I was not able to see error - running my app in android studio helped me.

LucasParsy commented 6 years ago

maybe you should update your readme, to redirect to the one of the "flutter_facebook_login" dependency. this library indeed issues the problem that it will crash if no Facebook information is provided in the app, and gives the instructions to setup Facebook's API keys.

What would be perfect is to make the dependency optional for users that don't want to integrate the facebook provider, and even better would be some error handling from "flutter_facebook_login" (which is not the place to issue this)

davidair commented 6 years ago

I think you can work around this by adding a fake facebook app id:

  1. Add the metadata to the Android manifest, under the application tag:
<meta-data android:name="com.facebook.sdk.ApplicationId"
    android:value="@string/facebook_app_id"/>
  1. Ensure android/app/src/main/res/values/strings.xml exists and contains the following:
<string name="facebook_app_id">00000000000</string>
yvanvds commented 5 years ago

Thanks, @davidair . That works for now. The file should look like this:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="facebook_app_id">00000000</string>
    </resources>

If you add the string directly, you'll get an error that it can't be found. Probably obvious if you work with Android a lot, but it took my a while to figure that out.