gpt4 book ai didi

android - "Argument ' 上下文 ' cannot be null"

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:39:23 25 4
gpt4 key购买 nike

我曾经在我的应用程序中使用 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)

我怀疑这是由以下 list 文件引起的。

<?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 提出了一个不存在上下文的不寻常声明:enter image description here

这是怎么回事?

最佳答案

我遇到了同样的异常,看起来新的 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

关于android - "Argument ' 上下文 ' cannot be null",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37878370/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com