我按照Facebook的教程集成了SDK,在我添加了.xml文件中的登录到Facebook按钮后,我的应用程序将编译,打开(在我的Nexus 4上运行Lollipop,针对kitkat的项目),然后崩溃.我正在全面更新
Android Studio.
logcat的:
02-07 22:48:24.340 1563-1600/com.example.prachi.mapsapplication E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1 Process: com.example.prachi.mapsapplication,PID: 1563 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 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) Caused by: 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:673) at com.facebook.widget.LoginButton$1.doInBackground(LoginButton.java:678) at com.facebook.widget.LoginButton$1.doInBackground(LoginButton.java:675) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 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)
.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" android:id="@+id/main"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Adventure Options" android:id="@+id/options" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="139dp" android:onClick="optionOnClick" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Random Adventure" android:id="@+id/random" android:layout_marginTop="57dp" android:onClick="randomOnClick" android:layout_below="@+id/authButton" android:layout_alignStart="@+id/options" /> <com.facebook.widget.LoginButton android:id="@+id/authButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_centerVertical="true" android:layout_centerHorizontal="true" />