Reputation: 2953
We are getting following error in account kit.
It would be very helpful if someone can tell its cause and how to fix it.
java.lang.RuntimeException:
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4155)
at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4246)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3360)
at android.app.ActivityThread.access$1100 (ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1794)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:158)
at android.app.ActivityThread.main (ActivityThread.java:7225)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by: java.lang.ArrayIndexOutOfBoundsException:
at com.facebook.accountkit.ui.PhoneCountryCodeAdapter.getItem (PhoneCountryCodeAdapter.java:253)
at com.facebook.accountkit.ui.PhoneContentController$TopFragment.setPhoneNumberText (PhoneContentController.java:435)
at com.facebook.accountkit.ui.PhoneContentController$TopFragment.onViewReadyWithState (PhoneContentController.java:362)
at com.facebook.accountkit.ui.ViewStateFragment.onActivityCreated (ViewStateFragment.java:66)
at com.facebook.accountkit.ui.PhoneContentController$TopFragment.onActivityCreated (PhoneContentController.java:201)
at android.app.Fragment.performActivityCreated (Fragment.java:2289)
at android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1007)
at android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1163)
at android.app.BackStackRecord.run (BackStackRecord.java:793)
at android.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:1552)
at android.app.FragmentController.execPendingActions (FragmentController.java:325)
at android.app.Activity.performResume (Activity.java:7014)
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4144)
So the line Caused by: java.lang.ArrayIndexOutOfBoundsException:
at com.facebook.accountkit.ui.PhoneCountryCodeAdapter.getItem
is caused due to piece of code written in the facebook library? Or it is something we can control and somehow change in through using the configuration files etc?
We are just using the https://developers.facebook.com/docs/accountkit/android in our app. It is working fine many devices, but some devices are getting above error.
Following the code for onCreate in the activity which is calling accountkit. And we are not using onResume.
SkinManager uiManager = new SkinManager(
SkinManager.Skin.CONTEMPORARY,
getResources().getColor(R.color.colorPrimary),
R.drawable.login_bg2,
SkinManager.Tint.WHITE,
0.55D);
intent = new Intent(this, AccountKitActivity.class);
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
new AccountKitConfiguration.AccountKitConfigurationBuilder(
LoginType.PHONE,
AccountKitActivity.ResponseType.TOKEN); // or .ResponseType.TOKEN
configurationBuilder.setSMSWhitelist(new String[]{"PK"});
configurationBuilder.setUIManager(uiManager);
intent.putExtra(
AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
configurationBuilder.build());
Response Starting to get the response.
startActivityForResult(intent, APP_REQUEST_CODE);
And here we are processing the response
@Override
protected void onActivityResult(
final int requestCode,
final int resultCode,
final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == APP_REQUEST_CODE) {
btnContinue.setEnabled(true);
// confirm that this response matches your request
final AccountKitLoginResult loginResult = data.getParcelableExtra(AccountKitLoginResult.RESULT_KEY);
if (loginResult.getError() != null) {
} else if (loginResult.wasCancelled()) {
} else {
progressDialog.show();
if(loginResult.getAccessToken()!=null){
fbAccessToken = loginResult.getAccessToken().getToken();
}
AccountKit.getCurrentAccount(new AccountKitCallback<Account>() {
@Override
public void onSuccess(Account account) {
PhoneNumber phoneNumber = account.getPhoneNumber();
phoneNumberString = phoneNumber.getPhoneNumber();
// some bla bla to call our APIs to save the response
}
@Override
public void onError(AccountKitError accountKitError) {
Log.e(TAG, "onError");
progressDialog.hide();
Toast.makeText(SignInActivity.this, accountKitError.getUserFacingMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
}
Upvotes: 0
Views: 329
Reputation: 387
Here is my final code.
public class AccountKitLoginManager {
public final static int APP_REQUEST_CODE = 99;
public static void login(Activity activity){
final Intent intent = new Intent(activity, AccountKitActivity.class);
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
new AccountKitConfiguration.AccountKitConfigurationBuilder(
LoginType.PHONE,
AccountKitActivity.ResponseType.CODE).setSMSWhitelist(new String[]{"MM"}); // or .ResponseType.TOKEN
intent.putExtra(
AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
configurationBuilder.build());
activity.startActivityForResult(intent, APP_REQUEST_CODE);
}
}
First error is same to you.Couse of this code String[]{"MM , CN"}.So I remove CN.My program is fine.
Upvotes: 0
Reputation: 1
Your must call
configurationBuilder.setDefaultCountryCode("PH");
I was also troubled by this problem for a long time.
Upvotes: 0