You didn’t add any code explaining the problem but after searching for this problem I found that you should add SDK initializes method in youronCreate() like the following
@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
}
To use Facebook Ads Sdk in your app, You must make an App class for your app and initialize the sdk there.
import android.app.Application;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
}
}
And set it in your manifest.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:name=".App" <!-- Name of your app class -->
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
........
........
</application>
</manifest>
I solved the issue with RAGIP MULLAMUSA’s answer (Sorry I don’t have enough reputation to vote or comment)
While I tried to upgrade the Facebook SDK from 9.x.x to latest (15.1.0), I found this error:
The Facebook sdk must be initialized before calling activateApp
I tried to put FacebookSdk.sdkInitialize(getApplicationContext()); before AppEventsLogger.activateApp(this);, and it doesn’t work. But the error will become:
A valid Facebook app client token must be set in the AndroidManifest.xml or set by calling FacebookSdk.setClientToken before initializing the sdk.
4
Answers
slove it by update gradle and add facebook client token in manifests
You didn’t add any code explaining the problem but after searching for this problem I found that you should add SDK initializes method in your
onCreate()
like the followingTo use Facebook Ads Sdk in your app, You must make an App class for your app and initialize the sdk there.
And set it in your manifest.
I solved the issue with RAGIP MULLAMUSA’s answer (Sorry I don’t have enough reputation to vote or comment)
While I tried to upgrade the Facebook SDK from 9.x.x to latest (15.1.0), I found this error:
I tried to put
FacebookSdk.sdkInitialize(getApplicationContext());
beforeAppEventsLogger.activateApp(this);
, and it doesn’t work. But the error will become:You might obtain the client token from https://developers.facebook.com/, and put it in AndroidManifest.xml
Note: You don’t need to keep
FacebookSdk.sdkInitialize(getApplicationContext());
after putting client token in manifest.I tried to put
FacebookSdk.setClientToken(YOUR_FACEBOOK_CLIENT_TOKEN);
beforesuper.onCreate();
, but it doesn’t work for me.