Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Official Facebook examples crashes (GraphApiSample)

I started to work with facebook-android-sdk-3.5.2.

The SDK project also contains varius sample examples for using the api like:

  • HelloFacebookSample: A simple activity you can log in and do stuff, it works great.

Next thing i wanted to try the next example called:

  • GraphApiSample, which i had problem with.

After i launch this app, i got this error: (Logcat):

11-11 15:22:40.008: E/AndroidRuntime(14048): FATAL EXCEPTION: main
11-11 15:22:40.008: E/AndroidRuntime(14048): java.lang.RuntimeException: Unable to resume activity {com.facebook.samples.graphapi/com.facebook.samples.graphapi.GraphApiSampleActivity}: java.lang.IllegalArgumentException: Both context and applicationId must be non-null
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2621)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2649)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.app.ActivityThread.access$700(ActivityThread.java:134)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.os.Looper.loop(Looper.java:137)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.app.ActivityThread.main(ActivityThread.java:4867)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at java.lang.reflect.Method.invokeNative(Native Method)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at java.lang.reflect.Method.invoke(Method.java:511)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at dalvik.system.NativeStart.main(Native Method)
11-11 15:22:40.008: E/AndroidRuntime(14048): Caused by: java.lang.IllegalArgumentException: Both context and applicationId must be non-null
11-11 15:22:40.008: E/AndroidRuntime(14048):    at com.facebook.AppEventsLogger.activateApp(AppEventsLogger.java:308)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at com.facebook.AppEventsLogger.activateApp(AppEventsLogger.java:292)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at com.facebook.samples.graphapi.GraphApiSampleActivity.onResume(GraphApiSampleActivity.java:76)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1199)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.app.Activity.performResume(Activity.java:5121)
11-11 15:22:40.008: E/AndroidRuntime(14048):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2611)

Well i see:

Caused by: java.lang.IllegalArgumentException: Both context and applicationId must be non-null

Okay, but i did not changed a thing in the code. It should be work, right?

I tried to:

  • Delete project, and import

  • Delete project, and add a new android project from existing code

  • Clean my project

  • Delete facebook sdk library dependency and reimport, then clean again.

Same result after all of these.

Please if somebody is familiar with this prob. help me.

E D I T:

For some reason, this official facebook sample does not contains appId. Thanks for the suggest!

like image 581
Adam Varhegyi Avatar asked Nov 11 '13 14:11

Adam Varhegyi


1 Answers

Try to set the app_id in the strings.xml or add it. It is also mentioned in the getting started tutorial here: Documentation

An additional step: Create a meta-data with the name com.facebook.sdk.ApplicationId and the value @string/app_id in AndroidManifest.xml

like image 136
A.S. Avatar answered Oct 21 '22 21:10

A.S.