darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
193 stars 127 forks source link

MissingPluginException(No implementation found for method login on channel app.meedu/flutter_facebook_auth) #257

Closed zatkontact closed 1 year ago

zatkontact commented 1 year ago

What version are you using?

flutter_facebook_auth:4.3.4+2

What OS and version are you using to local deploy your application?

macOS Monterey 12.4

What platforms are you seeing the problem on?

Android

Describe the Bug

I have recently upgraded to flutter 3.0.1 and upgraded this package to version 4.3.4+2. I followed the documentation via https://facebook.meedu.app and setup everything for ios and android. iOS is working fine but on android I am facing the MissingPluginException issue. I have tried many times today but haven't found any solution to this.

Expected Behavior

Should be able to login on android using this plugin.

To Reproduce

final LoginResult result = await FacebookAuth.instance.login();

Relevant log output

No response

flutter doctor -v

flutter doctor -v
[✓] Flutter (Channel stable, 3.0.1, on macOS 12.4 21F79 darwin-x64, locale en-AU)
    • Flutter version 3.0.1 at /Users/zat_km/Desktop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fb57da5f94 (4 weeks ago), 2022-05-19 15:50:29 -0700
    • Engine revision caaafc5604
    • Dart version 2.17.1
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/zat_km/Library/Android/sdk
    • Platform android-32, build-tools 33.0.0
    • Java binary at: /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home/bin/java
    • Java version Java(TM) SE Runtime Environment (build 14.0.2+12-46)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.68.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (3 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • macOS (desktop)         • macos         • darwin-x64     • macOS 12.4 21F79 darwin-x64
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 102.0.5005.115

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Info.plist (iOS)

No response

Podfile (iOS)

No response

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.spsc.kontact.android">
    <queries>
        <provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
    </queries>

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />

    <application
        android:name=".Application"
        android:extractNativeLibs="false"
        android:icon="@mipmap/kapp"
        android:label="@string/app_name"
        android:requestLegacyExternalStorage="true"
        android:allowBackup="false"
        android:usesCleartextTraffic="true">
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
        <meta-data
            android:name="com.facebook.sdk.ClientToken"
            android:value="@string/facebook_client_token" />

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@mipmap/kapp" />

        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />

        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:exported="true"
            android:windowSoftInputMode="adjustResize">
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme" />

            <meta-data
                android:name="io.flutter.embedding.android.SplashScreenDrawable"
                android:resource="@drawable/launch_background" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

        </activity>
        <!--
 Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java
        -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>

</manifest>

MainActivity.java

No response

MainActivity.kt

package com.spsc.kontact.android

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {

}

index.html

No response

Info.plist (macOS)

No response

darwin-morocho commented 1 year ago

@zatkontact your configuration seems right. make sure that you have the correct values in your strings.xml (facebook_app_id, facebook_client_token) and also after install and configure this plugin you must stop your project if it is running. Next if the problem persists try with flutter clean

zatkontact commented 1 year ago

@zatkontact your configuration seems right. make sure that you have the correct values in your strings.xml (facebook_app_id, facebook_client_token) and also after install and configure this plugin you must stop your project if it is running. Next if the problem persists try with flutter clean

@darwin-morocho I have tried that already. After flutter clean, tried with deleting app and re-install as well. still it is the same issue. Have been trying the whole day but no luck.

zatkontact commented 1 year ago

Am I missing any steps for configuring the plugin. Are there any additional steps that needs to be done within android studio except the manifest file?

darwin-morocho commented 1 year ago

@zatkontact MissingPluginException means that all plugins could not be loaded due to an error during the app initialization, in this case you must run the app in android studio and use the LOGCAT to watch the specific error

Gimposai commented 1 year ago

I'm having the same issue. This isn't related to this other issue I'm having is it? https://github.com/firebase/flutterfire/issues/8091

darwin-morocho commented 1 year ago

I'm having the same issue. This isn't related to this other issue I'm having is it? firebase/flutterfire#8091

@Gimposai Are you using flutterfire_ui with facebook authentication?

Gimposai commented 1 year ago

Are you using flutterfire_ui with facebook authentication?

Not that I'm aware of (Don't see flutterfire_ui in my pubspec.yaml).

darwin-morocho commented 1 year ago

@Gimposai please add your AndroidManifest.xml, strings.xml (hide your keys and token) and your MainActivity

zatkontact commented 1 year ago

I'm having the same issue. This isn't related to this other issue I'm having is it? firebase/flutterfire#8091

@Gimposai Are you using flutterfire_ui with facebook authentication?

@darwin-morocho I am using flutterfire with facebook authentication.

darwin-morocho commented 1 year ago

I'm having the same issue. This isn't related to this other issue I'm having is it? firebase/flutterfire#8091

@Gimposai Are you using flutterfire_ui with facebook authentication?

@darwin-morocho I am using flutterfire with facebook authentication.

@zatkontact flutterfire_ui uses flutter_facebook_auth:4.0.1 and you need to use the last version of this plugin so you can override the dependency using dependency_overrides

dependency_overrides:
  flutter_facebook_auth: 4.3.4+2

the problem is that you are using a facebook configuration for the last facebook sdk on Android and flutter_facebook_auth: ^4.0.1 uses the old configuration

darwin-morocho commented 1 year ago

I'm having the same issue. This isn't related to this other issue I'm having is it? firebase/flutterfire#8091

@Gimposai Are you using flutterfire_ui with facebook authentication?

@darwin-morocho I am using flutterfire with facebook authentication.

@zatkontact flutterfire_ui uses flutter_facebook_auth:4.0.1 and you need to use the last version of this plugin so you can override the dependency using dependency_overrides

dependency_overrides:
  flutter_facebook_auth: 4.3.4+2

the problem is that you are using a facebook configuration for the last facebook sdk on Android and flutter_facebook_auth: ^4.0.1 uses the old configuration

Or you can use the old configuration https://facebook.meedu.app/docs/3.x.x/android (DON'T forget to add the facebook queries in your AndroidManifest)

zatkontact commented 1 year ago

my bad. I am using flutterfire packages such as firebase_auth, firebase_messaging but not flutterfire ui. extremely sorry for the wrong information. however, is it going to be a good solution to use version 4.0.1 of flutter_facebook_auth and go back to old configuration? Or it should work with these firebase packages?

darwin-morocho commented 1 year ago

my bad. I am using flutterfire packages such as firebase_auth, firebase_messaging but not flutterfire ui. extremely sorry for the wrong information. however, is it going to be a good solution to use version 4.0.1 of flutter_facebook_auth and go back to old configuration? Or it should work with these firebase packages?

I don't think that. My recommendation is run your project in android studio and check the errors in the logcat could be that there is some plugin or dependency locking the plugins initialization

Gimposai commented 1 year ago

I apologize for formatting and the chaos (new to github and app development). Couldn't get it to look nice and neat like zat's. I honestly don't know what these files really do and only touch them when instructed...hope I hid all the values I was suppose to!

AndroidManifest.xml

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

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<!-- 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="${applicationName}"
    android:label="Eventings"
    android:icon="@mipmap/ic_launcher">
    <meta-data android:name="com.google.android.geo.API_KEY"
           android:value="###############################"/>
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <!-- Specifies an Android theme to apply to this Activity as soon as
             the Android process has started. This theme is visible to the user
             while the Flutter UI initializes. After that, this theme continues
             to determine the Window background behind the Flutter UI. -->
        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <!-- Displays an Android View that continues showing the launch screen
             Drawable until Flutter paints its first frame, then this splash
             screen fades out. A splash screen is useful to avoid any visual
             gap between the end of Android's launch screen and the painting of
             Flutter's first frame. -->
        <meta-data
          android:name="io.flutter.embedding.android.SplashScreenDrawable"
          android:resource="@drawable/launch_background"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <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>

    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>

< /manifest> `

strings.xml

` < ?xml version="1.0" encoding="utf-8"?> < resources> < string name="app_name">Eventings

<!-- Replace "000000000000" with your Facebook App ID here. -->
<string name="facebook_app_id">##############</string>

<!--
  Replace "000000000000" with your Facebook App ID here.
  **NOTE**: The scheme needs to start with `fb` and then your ID.
-->
<string name="fb_login_protocol_scheme">fb###############</string>

< /resources> `

MainActivity.kt

` package com.example.Eventings

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() { } `

darwin-morocho commented 1 year ago

I apologize for formatting and the chaos (new to github and app development). Couldn't get it to look nice and neat like zat's. I honestly don't know what these files really do and only touch them when instructed...hope I hid all the values I was suppose to!

AndroidManifest.xml

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

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<!-- 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="${applicationName}"
    android:label="Eventings"
    android:icon="@mipmap/ic_launcher">
    <meta-data android:name="com.google.android.geo.API_KEY"
           android:value="###############################"/>
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <!-- Specifies an Android theme to apply to this Activity as soon as
             the Android process has started. This theme is visible to the user
             while the Flutter UI initializes. After that, this theme continues
             to determine the Window background behind the Flutter UI. -->
        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <!-- Displays an Android View that continues showing the launch screen
             Drawable until Flutter paints its first frame, then this splash
             screen fades out. A splash screen is useful to avoid any visual
             gap between the end of Android's launch screen and the painting of
             Flutter's first frame. -->
        <meta-data
          android:name="io.flutter.embedding.android.SplashScreenDrawable"
          android:resource="@drawable/launch_background"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <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>

    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>

< /manifest> `

strings.xml

` < ?xml version="1.0" encoding="utf-8"?> < resources> < string name="app_name">Eventings

<!-- Replace "000000000000" with your Facebook App ID here. -->
<string name="facebook_app_id">##############</string>

<!--
  Replace "000000000000" with your Facebook App ID here.
  **NOTE**: The scheme needs to start with `fb` and then your ID.
-->
<string name="fb_login_protocol_scheme">fb###############</string>

< /resources> `

MainActivity.kt

` package com.example.Eventings

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() { } `

@Gimposai if you are using the last version of this plugin CustomTabActivity and FacebookActivity are not needed any more and also you must define your client token and the facebook queries

check https://facebook.meedu.app/docs/4.x.x/android

Gimposai commented 1 year ago

@darwin-morocho Facebook login is working for me now! Thank you so much!

han-tm commented 1 year ago

@darwin-morocho Facebook login is working for me now! Thank you so much!

What did you change to solve this problem? I've been struggling with this bug for 3 days now.

han-tm commented 1 year ago

Help, how to solve this error?

My MainActivity.kt

package com.sprestay.fdbks import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() {}

Manifest file:

`

<queries>
    <provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
</queries>
<application android:label="fb3" android:name="${applicationName}" android:icon="@mipmap/ic_launcher">
    <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
        <!-- Specifies an Android theme to apply to this Activity as soon as
             the Android process has started. This theme is visible to the user
             while the Flutter UI initializes. After that, this theme continues
             to determine the Window background behind the Flutter UI. -->
        <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
        <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token" />
    </activity>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data android:name="flutterEmbedding" android:value="2" />
</application>

`

`<?xml version="1.0" encoding="utf-8"?>

id token fbid

`

darwin-morocho commented 1 year ago

Help, how to solve this error?

My MainActivity.kt

package com.sprestay.fdbks import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() {}

Manifest file:

`

<queries>
    <provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
</queries>
<application android:label="fb3" android:name="${applicationName}" android:icon="@mipmap/ic_launcher">
    <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
        <!-- Specifies an Android theme to apply to this Activity as soon as
             the Android process has started. This theme is visible to the user
             while the Flutter UI initializes. After that, this theme continues
             to determine the Window background behind the Flutter UI. -->
        <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
        <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token" />
    </activity>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data android:name="flutterEmbedding" android:value="2" />
</application>

`

<?xml version="1.0" encoding="utf-8"?> <resources> <string name="facebook_app_id">id</string> <string name="facebook_client_token">token</string> <string name="fb_login_protocol_scheme">fbid</string> </resources>

check this example and compare with your configuration https://github.com/darwin-morocho/flutter-facebook-auth/tree/master/examples/with_provider

han-tm commented 1 year ago

Help, how to solve this error? My MainActivity.kt package com.sprestay.fdbks import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() {} Manifest file: `

<queries>
    <provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
</queries>
<application android:label="fb3" android:name="${applicationName}" android:icon="@mipmap/ic_launcher">
    <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
        <!-- Specifies an Android theme to apply to this Activity as soon as
             the Android process has started. This theme is visible to the user
             while the Flutter UI initializes. After that, this theme continues
             to determine the Window background behind the Flutter UI. -->
        <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
        <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token" />
    </activity>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data android:name="flutterEmbedding" android:value="2" />
</application>

<?xml version="1.0" encoding="utf-8"?> id token fbid `

check this example and compare with your configuration https://github.com/darwin-morocho/flutter-facebook-auth/tree/master/examples/with_provider

I did it, but my configuration same with this example

darwin-morocho commented 1 year ago

@han-tm your androidmanifest is wrong. the facebook meta tags are inside the MainActivity tag and they must be in the application tag

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

must be before </application>

check https://facebook.meedu.app/docs/4.x.x/android