Проблема с использованием Firebase Facebook и Google для входа на Android - PullRequest
2 голосов
/ 01 апреля 2019

Я не могу использовать вход через firebase через Facebook или Google в своем приложении Flutter.Он отлично работает на ios

. Он не получает подтверждение от провайдера и не выдает ошибку или ошибку.Это не работает на симуляторе или реальном устройстве.Вход по электронной почте работает идеально

Мой код входа:

final _auth = FirebaseAuth.instance;

    _auth.onAuthStateChanged.listen((user) {
      if (user != null) {
        //get useer data
      } else {
        //go to login page
      }
    });

Future<Null> _loginByFacebook(Completer completer) async {

  FacebookLogin facebookLogin = new FacebookLogin();
  FacebookLoginResult result = await facebookLogin.logInWithReadPermissions(['email', 'public_profile']);

  switch (result.status) {
    case FacebookLoginStatus.loggedIn:
      AuthCredential credential = FacebookAuthProvider.getCredential(accessToken: result.accessToken.token);
      FirebaseAuth.instance.signInWithCredential(credential);
      completer.complete();
      break;
    case FacebookLoginStatus.cancelledByUser:
      break;
    case FacebookLoginStatus.error:
      completer.completeError(result.errorMessage);
  }
}

Future<Null> _loginByGoogle( Completer completer) async {
  try {
    await GoogleSignIn().signIn();
    completer.complete();
  } catch (error) {

    completer.completeError(error);
    print(error);
  }
}

Мой AndroidManifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.app.android">

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="app"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

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

        <activity android:name="com.facebook.FacebookActivity"
            android:configChanges=
                    "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name" />

        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>
        <!--end facebook configuration-->
    </application>
</manifest>

Отладка информации, когда я пытаюсь использовать логин на Facebook:

D/        (19022): HostConnection::get() New Host Connection established 0x8fe3ca80, tid 19059
D/EGL_emulation(19022): eglMakeCurrent: 0x9cba4460: ver 2 0 (tinfo 0xa1283790)
I/flutter (19022): user not logged :`(
W/System  (19022): ClassLoader referenced unknown path: /system/app/Chrome/lib/x86
I/WebViewFactory(19022): Loading com.android.chrome version 51.0.2704.90 (code 275509012)
I/cr_LibraryLoader(19022): Time to load native libraries: 1 ms (timestamps 9943-9944)
I/cr_LibraryLoader(19022): Expected native library version number "51.0.2704.90", actual native library version number "51.0.2704.90"
V/WebViewChromiumFactoryProvider(19022): Binding Chromium to main looper Looper (main, tid 1) {2441051}
I/cr_LibraryLoader(19022): Expected native library version number "51.0.2704.90", actual native library version number "51.0.2704.90"
I/chromium(19022): [INFO:library_loader_hooks.cc(143)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_BrowserStartup(19022): Initializing chromium process, singleProcess=true
E/ApkAssets(19022): Error while loading asset assets/natives_blob_64.bin: java.io.FileNotFoundException: assets/natives_blob_64.bin
E/ApkAssets(19022): Error while loading asset assets/snapshot_blob_64.bin: java.io.FileNotFoundException: assets/snapshot_blob_64.bin
D/EGL_emulation(19022): eglCreateContext: 0x86b79440: maj 2 min 0 rcv 2
D/EGL_emulation(19022): eglMakeCurrent: 0x86b79440: ver 2 0 (tinfo 0x8b5c1ef0)
W/cr_media(19022): Requires BLUETOOTH permission
D/cr_Ime  (19022): [InputMethodManagerWrapper.java:30] Constructor
W/cr_AwContents(19022): onDetachedFromWindow called when already detached. Ignoring
D/cr_Ime  (19022): [InputMethodManagerWrapper.java:59] isActive: false
I/cr_Ime  (19022): ImeThread is not enabled.
E/libEGL  (19022): validate_display:99 error 3008 (EGL_BAD_DISPLAY)
I/VideoCapabilities(19022): Unsupported profile 4 for video/mp4v-es
D/        (19022): HostConnection::get() New Host Connection established 0x821595c0, tid 19100
D/EGL_emulation(19022): eglCreateContext: 0x82103120: maj 2 min 0 rcv 2
D/EGL_emulation(19022): eglMakeCurrent: 0x82103120: ver 2 0 (tinfo 0x827c98b0)
D/EGL_emulation(19022): eglMakeCurrent: 0xa1285cc0: ver 2 0 (tinfo 0xa1283840)
D/EGL_emulation(19022): eglMakeCurrent: 0xa1285cc0: ver 2 0 (tinfo 0xa1283840)
D/EGL_emulation(19022): eglMakeCurrent: 0xa1285cc0: ver 2 0 (tinfo 0xa1283840)
W/cr_BindingManager(19022): Cannot call determinedVisibility() - never saw a connection for the pid: 19022
D/cr_Ime  (19022): [InputMethodManagerWrapper.java:59] isActive: false
D/EGL_emulation(19022): eglMakeCurrent: 0xa1285cc0: ver 2 0 (tinfo 0xa1283840)
W/art     (19022): Attempt to remove non-JNI local reference, dumping thread
D/EGL_emulation(19022): eglMakeCurrent: 0xa1285cc0: ver 2 0 (tinfo 0xa1283840)

Когда я пытаюсь войти в Google, появляется только: D/EGL_emulation(19022): eglMakeCurrent: 0xa1285cc0: ver 2 0 (tinfo 0xa1283840)

Есть предположения, в чем может быть проблема?:)

ОБНОВЛЕНИЕ: я мог бы заставить его работать с помощью Google Sign, обновив код до:

Future<Null> _loginByGoogle( Completer completer) async {
  try {
    final GoogleSignIn _googleSignIn = GoogleSignIn();

    final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
    final GoogleSignInAuthentication googleAuth = await googleUser.authentication;


    final AuthCredential credential = GoogleAuthProvider.getCredential(
      accessToken: googleAuth.accessToken,
      idToken: googleAuth.idToken,
    );

    await _auth.signInWithCredential(credential);

    completer.complete();
  } catch (error) {

    completer.completeError(error.message);
    print(error);
  }
}

Но проблема с входом в Facebook осталась прежней.Когда он запрашивает логин, он не получает результат (успех или неудача)

...