I wanted to add the login button to my app and so i followed the guide of facebook about that. I created my app project i add an android project telling the name of the package and the path of the mainactivity and the hash code generated from the default keystore (i used as they tell to me the android debug keystore because for the moment the app is only in alfa test and so for personal developing reason i prefer to use the debug version generated from android studio). Then i put in string resource the app id and in the tag application the meta-data with facebook app id as the guide says. Then i set the enviroment as well:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
/**
*
*
* part dedicated to facebook button
*/
manager=CallbackManager.Factory.create();
setContentView(R.layout.activity_main);
loginButton=(LoginButton)findViewById(R.id.facebook_logi);
loginButton.setReadPermissions("email");
loginButton.registerCallback(manager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.i("Facebook","Login success");
}
@Override
public void onCancel() {
Log.i("Facebook","Login cencelled");
}
@Override
public void onError(FacebookException error) {
Log.i("Facebook","Login error "+error.getMessage());
}
});
/**
*
*
* end of facebook part
*/
and when i tried to run it the VM generate this exception
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:746)
at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:774)
at com.facebook.internal.FetchedAppSettingsManager.queryAppSettings(FetchedAppSettingsManager.java:147)
at com.facebook.login.widget.LoginButton$1.run(LoginButton.java:499)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
can anyone help me becouse i searched here for similar questions but i only found ones where people putted the meda-data with facebook_app_id outsidethe application tag..Thanks to all indeed.