java.lang.RuntimeException with Facebook Login example java.lang.RuntimeException with Facebook Login example multithreading multithreading

java.lang.RuntimeException with Facebook Login example


The problem is not coming from your code but from the facebook SDK. You can tell by looking at the top of the NullPointerException

Caused by: java.lang.NullPointerException        at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:781)        at com.facebook.internal.Utility.queryAppSettings(Utility.java:372)

The error last two triggering lines are from the facebook sdk (com.facebook.internal) and your java.util package neither of which are from your code.

To fix this, you need to finish the setup in the facebook's getting started tutorial for android where you register your app after generating an android key hash. After you've done that, open your AndroidManifest.xml and add the meta-data line

<application    android:allowBackup="true"    android:icon="@drawable/ic_launcher"    android:label="@string/app_name"    android:theme="@style/AppTheme" >    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>    <activity        android:name=".MainActivity"        android:label="@string/app_name" >        <intent-filter>            <action android:name="android.intent.action.MAIN" />            <category android:name="android.intent.category.LAUNCHER" />        </intent-filter>    </activity></application>

Then add your app_id into the strings.xml file (found from the settings page in your facebook developer accountThe app id is on your facebook developer account.

Once you've done this it should compile


<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

was missing in my case.


You need to add

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>

at right place inside the application not inside the activity