Dương Nguyễn Văn
Dương Nguyễn Văn

Reputation: 418

Crash Accountkit Facebook android AppEventsLogger

I received this logcat from user , when try to open Account kit via intent .

java.lang.NullPointerException 1 at com.facebook.accountkit.internal.AppEventsLogger.handleResponse(AppEventsLogger.java:526) 2 at com.facebook.accountkit.internal.AppEventsLogger.access$600(AppEventsLogger.java:57) 3 at com.facebook.accountkit.internal.AppEventsLogger$4.onCompleted(AppEventsLogger.java:510) 4 at com.facebook.accountkit.internal.AccountKitGraphRequestAsyncTask.onPostExecute(AccountKitGraphRequestAsyncTask.java:188) 5 at com.facebook.accountkit.internal.AccountKitGraphRequestAsyncTask.onPostExecute(AccountKitGraphRequestAsyncTask.java:42) 6 at android.os.AsyncTask.finish(AsyncTask.java:631) 7 at android.os.AsyncTask.access$600(AsyncTask.java:177) 8 at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644) 9 at android.os.Handler.dispatchMessage(Handler.java:99) 10 at android.os.Looper.loop(Looper.java:137) 11 at android.app.ActivityThread.main(ActivityThread.java:5041) 12 at java.lang.reflect.Method.invokeNative(Native Method) 13 at java.lang.reflect.Method.invoke(Method.java:511) 14 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 15 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 16 at dalvik.system.NativeStart.main(Native Metho

d)

React Native Account Kit version: 4+

Platform(s) (iOS, Android, or both?): Android

Need some feedback from you,please!

Thank alot!

Upvotes: 2

Views: 892

Answers (2)

Xingxing
Xingxing

Reputation: 61

Edit: now facebook team has fix this bug in account-kit-sdk 4.18.0

I found this bug many times in account-kit-sdk 4.17.0

afater read the deomplied class about AccountKitGraphResponse and AppEventsLogger

protected void onPostExecute(AccountKitGraphResponse result) {
        super.onPostExecute(result);
        if(result != null && result.getError() != null && result.getError().getException().getError().getErrorType() == Type.NETWORK_CONNECTION_ERROR && result.getError().getException().getError().getDetailErrorCode() != 101 && this.numRetries < 4) {
            Handler mainHandler = new Handler(AccountKitController.getApplicationContext().getMainLooper());
            mainHandler.post(new Runnable() {
                public void run() {
                    int newNumRetries = AccountKitGraphRequestAsyncTask.this.numRetries + 1;
                    final AccountKitGraphRequestAsyncTask asyncTask = new AccountKitGraphRequestAsyncTask((HttpURLConnection)null, AccountKitGraphRequestAsyncTask.this.request, AccountKitGraphRequestAsyncTask.this.callback, newNumRetries, null);
                    Utility.getBackgroundExecutor().schedule(new Runnable() {
                        public void run() {
                            if(!AccountKitGraphRequestAsyncTask.this.isCancelled() && !asyncTask.isCancelled()) {
                                asyncTask.executeOnExecutor(Utility.getThreadPoolExecutor(), new Void[0]);
                            }

                        }
                    }, (long)(5 * newNumRetries), TimeUnit.SECONDS);
                    if(AccountKitGraphRequestAsyncTask.this.request.isLoginRequest()) {
                        AccountKitGraphRequestAsyncTask.currentAsyncTask = asyncTask;
                    }

                }
            });
        } else {
            if(this.callback != null) {
                this.callback.onCompleted(result);
            }

            if(this.exception != null) {
                Log.d(TAG, String.format("onPostExecute: exception encountered during request: %s", new Object[]{this.exception.getMessage()}));
            }

        }
    }

private void handleResponse(AppEventsLogger.SessionEventsStateKey stateKey, AccountKitGraphRequest request, AccountKitGraphResponse response, AppEventsLogger.SessionEventsState sessionEventsState, AppEventsLogger.FlushStatistics flushState) {
        AccountKitRequestError error = response.getError();
        String resultDescription = "Success";
        ...
    }

the this.callback.onCompleted(result); method invoked, that will run AppEventsLogger.this.handleResponse(stateKey, postRequest, response, sessionEventsState, flushState);, in some case, response is null object that will cause NullPointerException

I suggest that this change

if(this.callback != null && result != null) {
   this.callback.onCompleted(result);
}

Upvotes: 0

John Anderson
John Anderson

Reputation: 159

This looks similar to this bug

https://developers.facebook.com/bugs/296907867375696/

It says that a fix is rolling out in the next release.

Upvotes: 0

Related Questions