我尝试在我的应用中添加facebook登录按钮,即使成功编译后它也会在模拟器中崩溃。
以下是根据logcat的错误报告,请帮我解决。
由于
06-12 15:10:39.983 18518-18518/? I/art﹕ Late-enabling -Xcheck:jni
06-12 15:10:41.167 18518-18528/com.example.prashant.nuhani_go W/art﹕ Suspending all threads took: 361.261ms
06-12 15:10:41.353 18518-18518/com.example.prashant.nuhani_go D/Key Hash:-﹕ gMvqxy6TyRo8c0U4xwDiHZhq8gY=
06-12 15:10:41.363 18518-18543/com.example.prashant.nuhani_go D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-12 15:10:41.367 18518-18518/com.example.prashant.nuhani_go D/﹕ HostConnection::get() New Host Connection established 0xb42d68e0, tid 18518
06-12 15:10:41.377 18518-18518/com.example.prashant.nuhani_go D/Atlas﹕ Validating map...
06-12 15:10:41.471 18518-18543/com.example.prashant.nuhani_go D/libEGL﹕ loaded /system/lib/egl/libEGL_emulation.so
06-12 15:10:41.472 18518-18543/com.example.prashant.nuhani_go D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_emulation.so
06-12 15:10:41.484 18518-18543/com.example.prashant.nuhani_go D/libEGL﹕ loaded /system/lib/egl/libGLESv2_emulation.so
06-12 15:10:41.502 18518-18543/com.example.prashant.nuhani_go D/﹕ HostConnection::get() New Host Connection established 0xaf0395c0, tid 18543
06-12 15:10:41.530 18518-18543/com.example.prashant.nuhani_go I/OpenGLRenderer﹕ Initialized EGL, version 1.4
06-12 15:10:41.709 18518-18543/com.example.prashant.nuhani_go D/OpenGLRenderer﹕ Enabling debug mode 0
06-12 15:10:41.760 18518-18543/com.example.prashant.nuhani_go W/EGL_emulation﹕ eglSurfaceAttrib not implemented
06-12 15:10:41.760 18518-18543/com.example.prashant.nuhani_go W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xaf0358a0, error=EGL_SUCCESS
06-12 15:10:41.970 18518-18518/com.example.prashant.nuhani_go I/Choreographer﹕ Skipped 33 frames! The application may be doing too much work on its main thread.
06-12 15:10:41.988 18518-18553/com.example.prashant.nuhani_go E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #4
Process: com.example.prashant.nuhani_go, PID: 18518
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.Utility.queryAppSettings(Utility.java:825)
at com.facebook.login.widget.LoginButton$1.run(LoginButton.java:486)
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)
06-12 15:10:43.514 18518-18518/com.example.prashant.nuhani_go I/Choreographer﹕ Skipped 92 frames! The application may be doing too much work on its main thread.

和我的activity.java代码片段如下
package com.example.prashant.nuhani_go;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import android.content.pm.Signature;
import com.facebook.FacebookSdk;
public class learningActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_learning);
getUserInfo();
}
public void getUserInfo() {
try{
PackageInfo info= getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
for(Signature signature:info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("Key Hash:- ", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
}
catch (PackageManager.NameNotFoundException e) {}
catch (NoSuchAlgorithmException e){}
}
}