«Аргумент« контекст »не может быть нулевым»

Раньше у меня была кнопка входа в Facebook в течение 5 месяцев, и она работала точно так же, как и предполагалось … до сегодняшнего дня. Это 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> Размер <?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 делает необычное утверждение, что нет никакого контекста: Введите описание изображения здесь

Что тут происходит?

У меня такое же исключение, похоже, что что-то не так с новым SDK для facebook, я предлагаю вернуться к предыдущей версии.

Я изменил свой 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

Intereting Posts