3

我添加了用于验证手机号码的 Fabric Digit 套件。手机号码已成功验证,但是当我单击验证按钮时应用程序崩溃并且当我重新打开应用程序时,数字会话已成功创建,我在许多应用程序中使用了数字但没有得到问题所在。可能是特定版本或其他?

崩溃日志:

#0. Crashed: IntentService[ATTRIBUTABLE_INVITE_DOWNLOAD_WORKER]: 0 0 0x0000000000000000
       at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:772)
       at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:800)
       at com.digits.sdk.android.DigitsApiClientManager.getUserAuthClient(DigitsApiClientManager.java:53)
       at com.digits.sdk.android.AttributableInviteDownloadService.onHandleIntent(AttributableInviteDownloadService.java:55)
       at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.os.HandlerThread.run(HandlerThread.java:61)

--

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
       at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:772)
       at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:800)
       at com.digits.sdk.android.DigitsApiClientManager.getUserAuthClient(DigitsApiClientManager.java:53)
       at com.digits.sdk.android.AttributableInviteDownloadService.onHandleIntent(AttributableInviteDownloadService.java:55)
       at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.os.HandlerThread.run(HandlerThread.java:61)

Crashalytics在此处添加了更详细的日志

在应用程序中实现的代码:

创建

authCallback = new AuthCallback() {
                    @Override
                    public void success(DigitsSession session, String phoneNumber) {
                        Log.d("msg", "session : " + session.toString() + " " + phoneNumber);
                        MOBILE_NO = phoneNumber;
                        storeUserData.setString(Constants.USER_MOBILE, phoneNumber);
                        Digits.clearActiveSession();
                        startActivity(new Intent(activity, RegisterActivity.class)
                                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                    }

                    @Override
                    public void failure(DigitsException error) {
                        error.printStackTrace();
                    }
                };

用于验证

binding.authButton.setCallback(authCallback);
                            binding.authButton.setAuthTheme(R.style.CustomDigitsTheme);

                            AuthConfig.Builder authConfigBuilder = new AuthConfig.Builder()
                                    
                                    .withAuthCallBack(authCallback)
                                    .withPhoneNumber("+91");

                            Digits.authenticate(authConfigBuilder.build());

4

2 回答 2

1

你可以试试下面的代码,

DigitsAuthButton digitsButton;
AuthCallback authcallback;
 digitsButton = (DigitsAuthButton) view.findViewById(R.id.auth_button);
        digitsButton.setAuthTheme(R.style.CustomDigitsTheme);
        authcallback = new AuthCallback() {
            @Override
            public void success(DigitsSession session, String phoneNumber) {
                edtMobNumber.setText(phoneNumber);
            }

            @Override
            public void failure(DigitsException exception) {

                exception.printStackTrace();

            }
        };
        digitsButton.setCallback(authcallback);
//launching digits activity on click of edit text
edtMobNumber.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Digits.clearActiveSession();
        digitsButton.performClick();
    }
});

请让我知道这对你有没有用。

于 2017-04-15T06:14:39.640 回答
0

我遇到了同样的问题,发现我正在清除回调方法中的活动会话(注销)。

删除这一行:

Digits.clearActiveSession();

或者就我而言,我删除了这一行:

Digits.logout();
于 2017-04-26T22:36:59.530 回答