我以前在我的应用程序中有5个月的Facebook登录按钮,它按预期工作......直到今天。这个NullPointerException
出现了:
java.lang.NullPointerException: Argument 'context' cannot be null
at com.facebook.internal.Validate.notNull(Validate.java:76)
at com.facebook.internal.Utility.getMetadataApplicationId(Utility.java:594)
at com.facebook.appevents.AppEventsLogger.<init>(AppEventsLogger.java:757)
at com.facebook.appevents.AppEventsLogger.<init>(AppEventsLogger.java:732)
at com.facebook.appevents.AppEventsLogger.newLogger(AppEventsLogger.java:400)
at com.facebook.FacebookButtonBase.logButtonCreated(FacebookButtonBase.java:225)
at com.facebook.FacebookButtonBase.onAttachedToWindow(FacebookButtonBase.java:136)
at com.facebook.login.widget.LoginButton.onAttachedToWindow(LoginButton.java:452)
at android.view.View.dispatchAttachedToWindow(View.java:14514)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1364)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
我怀疑它是由以下清单文件引起的。:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="orange.oaca">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/logooaca"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".Configs.AppController">
<!-- Notice this tag which provides the database name -->
<meta-data
android:name="OACA"
android:value="OACA.db" />
<!-- Notice this tag which provides the database version -->
<meta-data
android:name="DB_VERSION"
android:value="1" />
<meta-data
android:name="AA_MODELS"
android:value="orange.oaca.model.User,orange.oaca.model.Vol,orange.oaca.model.Airport,orange.oaca.model.CategorieServiceIn" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCUMuMhGrrTdt44y2XZ5hwNPO9CqeLBxSM" />
<activity
android:name=".SignUp"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".HomeActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name=".CreerCompte"
android:label="@string/title_activity_creer_compte"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".FlightListView"
android:label="@string/title_activity_flight_list_view"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".AirportListView"
android:label="@string/title_activity_airport_list_view"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".DetailVol"
android:label="@string/title_activity_detail_vol"
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>
此外,Android Studio正在提出一个不寻常的声明:
这里发生了什么?
答案 0 :(得分:16)
我得到了相同的异常,看起来新的facebook SDK出了问题,我建议切换回以前的版本。
我改变了我的build.gradle
from: compile 'com.facebook.android:facebook-android-sdk:4.+
to: compile 'com.facebook.android:facebook-android-sdk:4.12.1'
这解决了我的问题。
sdk版本列表位于:https://developers.facebook.com/docs/android/downloads