I have FacebookSdk.sdkInitialize(getApplicationContext())
where sdkInitialize() is displayed as deprecated. According to this article we can just delete that line. But then I get following error for the line after AppEventsLogger.activateApp(this)
:
AndroidRuntime: FATAL EXCEPTION: main Process: com.daimler.moovel.android:auth, PID: 4011 java.lang.RuntimeException: Unable to create application com.daimler.moovel.android.DebugApplication: The Facebook sdk must be initialized before calling activateApp at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5879) at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: The Facebook sdk must be initialized before calling activateApp
at com.facebook.appevents.AppEventsLogger.activateApp(AppEventsLogger.java:226)
at com.facebook.appevents.AppEventsLogger.activateApp(AppEventsLogger.java:208)
So what am I missing?
No need of AppEventsLogger.activateApp(this);
now it is not required if you have set up facebook_id in manifest.xml
u just have to add following in Application tag in manifest.xml
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
where facebook_app_id is defined in string.xml
That is because you upgraded your Facebook SDK
and you are trying to use implemention of AppEventsLogger
providinig this
as Context
:
AppEventsLogger.activateApp(this);
and that is replaced from SDK 4.19 and above with:
AppEventsLogger.activateApp(getApplication());
Documentation about this says:
Notifies the events system that the app has launched and activate and deactivate events should start being logged automatically. This should be called from the OnCreate method of you application.
That have logic if Facebook SDK
now is auto initialized on Application start.
Try that I hope this will solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With