我正在關注android33 sdk的https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/,所有事情都很好,因爲它在給定的lik上描述,但是當我運行我的項目時,我得到了錯誤「不幸'appname'已停止工作」這裏是我的logcat錯誤:不幸的是,「appname」已停止工作
09-26 17:37:06.662: E/AndroidRuntime(5849): FATAL EXCEPTION: main
09-26 17:37:06.662: E/AndroidRuntime(5849): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.hellofriend/com.facebook.hellofriend.MainActivity}: java.lang.NullPointerException: Argument 'applicationId' cannot be null
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202)
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237)
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.app.ActivityThread.access$600(ActivityThread.java:139)
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.os.Looper.loop(Looper.java:154)
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.app.ActivityThread.main(ActivityThread.java:4974)
09-26 17:37:06.662: E/AndroidRuntime(5849): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 17:37:06.662: E/AndroidRuntime(5849): at java.lang.reflect.Method.invoke(Method.java:511)
09-26 17:37:06.662: E/AndroidRuntime(5849): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-26 17:37:06.662: E/AndroidRuntime(5849): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-26 17:37:06.662: E/AndroidRuntime(5849): at dalvik.system.NativeStart.main(Native Method)
09-26 17:37:06.662: E/AndroidRuntime(5849): Caused by: java.lang.NullPointerException: Argument 'applicationId' cannot be null
09-26 17:37:06.662: E/AndroidRuntime(5849): at com.facebook.internal.Validate.notNull(Validate.java:29)
09-26 17:37:06.662: E/AndroidRuntime(5849): at com.facebook.Session.<init>(Session.java:227)
09-26 17:37:06.662: E/AndroidRuntime(5849): at com.facebook.Session.<init>(Session.java:216)
09-26 17:37:06.662: E/AndroidRuntime(5849): at com.facebook.Session$Builder.build(Session.java:1575)
09-26 17:37:06.662: E/AndroidRuntime(5849): at com.facebook.Session.openActiveSession(Session.java:888)
09-26 17:37:06.662: E/AndroidRuntime(5849): at com.facebook.Session.openActiveSession(Session.java:830)
09-26 17:37:06.662: E/AndroidRuntime(5849): at com.facebook.hellofriend.MainActivity.onCreate(MainActivity.java:19)
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.app.Activity.performCreate(Activity.java:4538)
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
09-26 17:37:06.662: E/AndroidRuntime(5849): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2158)
09-26 17:37:06.662: E/AndroidRuntime(5849): ... 11 more
謝謝。
我的清單文件是:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.facebook.hellofriend.MainActivity"
android:label="@string/app_name" >
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="21907****928145"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
這裏是我的新的logcat錯誤:( 09-26 18:55:54.564:E/AndroidRuntime(11123):致命異常:主要 09 -26 18:55:54.564:E/AndroidRuntime(11123):java.lang.RuntimeException:無法啓動活動ComponentInfo {com.facebook.hellofriend/com.facebook.hellofriend.MainActivity}:java.lang.NullPointerException:Argument' applicationId'不能爲null 09-26 18:55:54.564:E/AndroidRuntime(11123):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202) 09-26 18:55:54.564:E/AndroidRuntime(11123):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237) 09-26 18:55:54.564:E/AndroidRuntime(11123):at android.app.ActivityThread.access $ 600(ActivityThread.java:139) 09-26 18:55:54.564:E/AndroidRuntime(11123):at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1262) 09-26 18:55:54.564:E/AndroidRuntime(11123):at android.os.Handler.dispatchMessage(Handler.java:99) 09-26 18:55:54.564:E/AndroidRuntime(11123):at android .os.Looper.loop(Looper.java:154) 09-26 18:55:54.564:E/AndroidRuntime(11123):at android.app.ActivityThread.main(ActivityThread.java:4974) 09-26 18 :55:54.564:E/AndroidRuntime(11123):at java.lang.reflect.Method.invokeNative(Native Method) 09-26 18:55:54.564:E/AndroidRuntime(11123):at java.lang.reflect.Method.invoke(Method.java:511) 09-26 18:55:54.564:E/AndroidRuntime(11123):at com。 android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:784) 09-26 18:55:54.564:E/AndroidRuntime(11123):at com.android.internal.os.ZygoteInit.main(ZygoteInit。 java:551) 09-26 18:55:54.564:E/AndroidRuntime(11123):at dalvik.system.NativeStart.main(Native Method) 09-26 18:55:54.564:E/AndroidRuntime(11123):由於:java.lang.NullPointerException:參數'applicationId'不能爲空 09-26 18:55:54.564:E/AndroidRuntime(11123):at com.facebook.internal.Validate.notNull(Validate.java:29) 09-26 18:55:54.564:E/AndroidRuntime(11123):at com.facebook.Session。(Session.java:227) 09-26 18:55:54.564:E/AndroidRun time(11123):at com.facebook.Session。(Session.java:216) 09-26 18:55:54.564:E/AndroidRuntime(11123):at com.facebook.Session $ Builder.build(Session.java :1575) 09-26 18:55:54.564:E/AndroidRuntime(11123):at com.facebook.Session.openActiveSession(Session.java:888) 09-26 18:55:54.564:E/AndroidRuntime(11123 ):at com.facebook.Session.openActiveSession(Session.java:830) 09-26 18:55:54.564:E/AndroidRuntime(11123):at com.facebook.hellofriend.MainActivity.onCreate(MainActivity.java:19 ) 09-26 18:55:54.564:E/AndroidRuntime(11123):at android.app.Activity.performCreate(Activity.java:4538) 09-26 18:55:54.564:E/AndroidRuntime(11123):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071) 09-26 18:55:54.564:E/AndroidRuntime(11123):at android.app.Acti vityThread.performLaunchActivity(ActivityThread.java:2158) 09-26 18:55:54.564:E/AndroidRuntime(11123):...11多
''applicationId'不能爲空'? – RobinHood
@RobinHood已經給出了我的應用程序ID在string.xml ******************** 如果你在談論另一個然後PLZ讓我知道那個謝謝。 –
發佈此類代碼! – RobinHood