Maliffic / firebase_ui

MIT License
45 stars 48 forks source link

Dependency on firebase_ui makes app crash on startup #6

Open aberent opened 5 years ago

aberent commented 5 years ago

When I tried to use firebase_ui my Android app started to crash on startup. Having removed all the firebase_ui code from the app it still crashed on startup. On further investigation I discovered it crashed if, and only if, firebase_ui was included in the dependencies in pubspec.yaml.

The error in the logcat is: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.xxx_dummy/com.xxx.xxx_dummy.MainActivity}: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.

Why does adding firebase_ui (unused) to the dependencies require me to initialise FacebookSdk?

LazyDave76 commented 5 years ago

Hey There @aberent, I had the same problem as you - added the firebase_ui dependency to my pubspec and Boom! the example flutter app broke.

After scratching about on the 'net, I found an implementation guide for android that suggests adding additional meta-data to the AndroidManifest.xml file so it looks something like this:

<application
        android:name="io.flutter.app.FlutterApplication"
        android:label="flutter_app"
        android:icon="@mipmap/ic_launcher">

   <meta-data android:name="com.facebook.sdk.ApplicationId" 
            android:value="@string/facebook_app_id"/>

   <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            .....>
            ....
    </activity>

an additional res/strings.xml file needs to be created with this in:

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

Obviously, this doesn't answer the original question but does treat the symptom. You will see lots of errors in your console that look like this : E/GraphResponse( 4069): {HttpStatus: 400, errorCode: 100, subErrorCode: 33, errorType: GraphMethodException, errorMessage: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api}

But at least your app will run.

Hope this helps!

daniele-sforza commented 4 years ago

Hey There @aberent, I had the same problem as you - added the firebase_ui dependency to my pubspec and Boom! the example flutter app broke.

After scratching about on the 'net, I found an implementation guide for android that suggests adding additional meta-data to the AndroidManifest.xml file so it looks something like this:

<application
        android:name="io.flutter.app.FlutterApplication"
        android:label="flutter_app"
        android:icon="@mipmap/ic_launcher">

   <meta-data android:name="com.facebook.sdk.ApplicationId" 
            android:value="@string/facebook_app_id"/>

   <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            .....>
            ....
    </activity>

an additional res/strings.xml file needs to be created with this in:

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

Obviously, this doesn't answer the original question but does treat the symptom. You will see lots of errors in your console that look like this : E/GraphResponse( 4069): {HttpStatus: 400, errorCode: 100, subErrorCode: 33, errorType: GraphMethodException, errorMessage: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api}

But at least your app will run.

Hope this helps!

Thanks for this. I was having this issue and I can run my app now. The strings.xml file has to be created under res/values/ though