Open eav-solution opened 2 years ago
@eav-solution please add your AndroidManifest.xml
@eav-solution please add your AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.eav.perdex">
<queries>
<provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
</queries>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_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:icon="@mipmap/ic_launcher"
android:label="Perdex">
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="528057332253406" />
<meta-data
android:name="com.facebook.sdk.ClientToken"
android:value="792755a6c24c1b6e13f0f76331b5a954" />
<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: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>
<!-- 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>
I added, thanks you your support!
@eav-solution please add your AndroidManifest.xml
<queries> <provider android:authorities="com.facebook.katana.provider.PlatformProvider" /> </queries> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_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:icon="@mipmap/ic_launcher" android:label="Perdex"> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="528057332253406" /> <meta-data android:name="com.facebook.sdk.ClientToken" android:value="792755a6c24c1b6e13f0f76331b5a954" /> <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: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> <!-- 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>
I added, thanks you your support!
After install the plugin. Have you stopped the project and run it again?
Also don't forget the internet permission <uses-permission android:name="android.permission.INTERNET" />
@eav-solution please add your AndroidManifest.xml
<queries> <provider android:authorities="com.facebook.katana.provider.PlatformProvider" /> </queries> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_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:icon="@mipmap/ic_launcher" android:label="Perdex"> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="528057332253406" /> <meta-data android:name="com.facebook.sdk.ClientToken" android:value="792755a6c24c1b6e13f0f76331b5a954" /> <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: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> <!-- 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>
I added, thanks you your support!
After install the plugin. Have you stopped the project and run it again?
Also don't forget the internet permission
<uses-permission android:name="android.permission.INTERNET" />
I cleaned project couple times and still got error with INTERNET permission added.
@eav-solution If you have a custom MainApplication class or MainActivity please add them.
I don't modify MainActivity.kt file. But MainActivity class doesn't have any thing in it class MainActivity{ }
@eav-solution If you have a custom MainApplication class or MainActivity please add them.
package com.eav.perdex
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() { }
Same
Doesn't have android package ?
I have the same issue (in the Android emulator on Linux). The following steps don't solve the problem for me:
cd android
./gradlew clean build
cd ..
flutter clean
flutter run
My MainActivity
is not modified. I have the INTERNET
permission enabled.
I ran ./gradlew -d
and checked the debug output. All the build steps for flutter_facebook_auth
seem to be being performed as expected.
I also see in android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
:
flutterEngine.getPlugins().add(new app.meedu.flutter_facebook_auth.FlutterFacebookAuthPlugin());
so the plugin is in fact loaded. I don't know why the method channel app.meedu.flutter_facebook_auth
is not being registered.
I found the issue: when FlutterFacebookAuthPlugin
calls new FacebookAuth()
, the following exception is thrown, which causes the plugin registration to fail:
The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
FacebookSdk.sdkInitialize()
is now deprecated, and initialization is done by means of a ContentProvider
declared in the manifest:
https://stackoverflow.com/a/41884415/3950982
This means the com.facebook.android/facebook-core
library should be initializing itself. However it is not, for some reason.
This ContentProvider
, named FacebookInitProvider
, is being correctly registered in the facebook-core
library, so it should be run on startup:
I tried manually adding the facebook-core
library as a dependency in my app, and that did not force the FacebookInitProvider
to be run on startup.
I looked at build/app/intermediates/merged_manifest/debug/AndroidManifest.xml
, and the provider is being correctly declared there:
<provider
android:name="com.facebook.internal.FacebookInitProvider"
android:authorities="app.myapp.FacebookInitProvider"
android:exported="false" />
Anyone have any ideas about what is going wrong?
OK, I solved it by setting a method breakpoint at class com.facebook.internal.FacebookInitProvider
, method onCreate
. It turns out the initialization was failing because the app id couldn't be found in my manifest file. I guess if a ContentProvider
fails to initialize, nothing is written to the log :-/
The following two lines need to be in <manifest><application>...
, not inside <manifest>...
. (I didn't read the docs closely enough...)
<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"/>
This fixes the issue for me.
Actually, the error is: App Ids cannot be directly placed in the manifest.They must be prefixed by 'fb' or be placed in the string resource file. I solved it by prefixing 'fb'. @eav-solution
I had the same problem. I added the app id and client token directly to the manifest file. I added "fb" to the App ID (fb1234). My problem is solved
Problem solved by adding "fb" before the App ID 👍🏾. Could this be added to the doc?
Problem solved by adding "fb" before the App ID 👍🏾.
Could this be added to the doc?
In fact the documentación has an example with real data to configure the sdk on android
I'm getting the The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize()
first.
Here's my AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.education.myschoollibrary">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
tools:node="remove" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
tools:node="remove" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="31" />
<queries>
<provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
</queries>
<application
android:label="My School Library"
android:name="${applicationName}"
android:icon="@mipmap/launcher_icon"
tools:node="replace">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxx"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
<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">
<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>
</activity>
<!-- Facebook SDK // START-->
<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"/>
<!-- Facebook SDK // END-->
<!-- 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" />
<!-- Begin FlutterDownloader customization -->
<!-- disable default Initializer -->
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>
<!-- declare customized Initializer -->
<provider
android:name="vn.hunghd.flutterdownloader.FlutterDownloaderInitializer"
android:authorities="${applicationId}.flutter-downloader-init"
android:exported="false">
<meta-data
android:name="vn.hunghd.flutterdownloader.MAX_CONCURRENT_TASKS"
android:value="1" />
</provider>
<!-- End FlutterDownloader customization -->
</application>
</manifest>
What version are you using?
5.0.6
What OS and version are you using to local deploy your application?
MacOS 13
What platforms are you seeing the problem on?
Android
pubspec.yaml
Describe the Bug
Cannot sign in with facebook.
Expected Behavior
Login facebook succesful.
To Reproduce
Future signInWithFacebook() async {
// Trigger the sign-in flow
final LoginResult loginResult = await FacebookAuth.instance.login();
// Create a credential from the access token final OAuthCredential facebookAuthCredential = FacebookAuthProvider.credential(loginResult.accessToken.token);
// Once signed in, return the UserCredential return FirebaseAuth.instance.signInWithCredential(facebookAuthCredential); }
Relevant log output
No response
flutter doctor -v
Info.plist (iOS)
No response
Podfile (iOS)
No response
AndroidManifest.xml
No response
MainActivity.java
No response
MainActivity.kt
No response
index.html
No response
Info.plist (macOS)