java – doInBackground()错误在facebook api在android工作室

前端之家收集整理的这篇文章主要介绍了java – doInBackground()错误在facebook api在android工作室前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我按照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" />

解决方法

如果您没有在您的清单应用程式标签中加入应用程式编号,就会崩溃.
如果是这样,请确保您的应用程序已在您的Facebook开发者帐户中注册,并将其添加到您的字符串值中.
<string name="app_id">XXXXXXXXXXXXXXX</string>

之后,将以下内容放在清单中的应用程序标签中:

<Meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
原文链接:https://www.f2er.com/android/126528.html

猜你在找的Android相关文章