hello everyone i have error in my android/java project
E/AndroidRuntime: FATAL EXCEPTION: main
Caused by: The Facebook sdk must be initialized before calling activateApp
screenshots:
CodePudding user response:
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);
}
CodePudding user response:
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>