【问题标题】:Crash Accountkit Facebook android AppEventsLogger崩溃 Accountkit Facebook android AppEventsLogger
【发布时间】:2017-03-22 13:05:24
【问题描述】:

当我尝试通过意图打开帐户工具包时,我从用户那里收到了这个 logcat。

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

d)

React Native Account Kit 版本:4+

平台(iOS、Android 或两者兼有?):Android

需要您的反馈!

非常感谢!

【问题讨论】:

    标签: android facebook account-kit


    【解决方案1】:

    编辑:现在 facebook 团队已经在 account-kit-sdk 4.18.0 中修复了这个错误

    我在 account-kit-sdk 4.17.0 中多次发现这个错误

    之后阅读了关于AccountKitGraphResponseAppEventsLogger 的反编译类

    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";
            ...
        }
    

    调用的this.callback.onCompleted(result); 方法将运行AppEventsLogger.this.handleResponse(stateKey, postRequest, response, sessionEventsState, flushState);,在某些情况下,responsenull 对象 这将导致 NullPointerException

    我建议这个改变

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

    【讨论】:

      【解决方案2】:

      这看起来类似于这个错误

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

      它表示将在下一个版本中推出修复程序。

      【讨论】:

        猜你喜欢
        • 2013-09-25
        • 1970-01-01
        • 2013-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-08
        • 2013-05-13
        • 2018-02-04
        相关资源
        最近更新 更多