I'm trying to integrate Facebook AccountKit to allow users to sign-up with their e-mail or phone number. But when launching the AccountKitActivity, the app crash because it can't inflate a "ConstrainedLayout".
Error message :
java.lang.RuntimeException: Unable to start activity
android.view.InflateException: Binary XML file line #45:
Error inflating class com.facebook.accountkit.ui.ConstrainedLinearLayout
And below:
Caused by: java.lang.UnsupportedOperationException:
Failed to resolve attribute at index 12:
TypedValue{t=0x3/d=0x512 "res/drawable/scrollbar_handle_material.xml" a=1 r=0x10805cd}
I'm using in my gradle:
compile 'com.facebook.android:facebook-android-sdk:4.11.0'
compile 'com.facebook.android:account-kit-sdk:4.11.0'
I'm calling AccountKit.initialize() before trying to launch the AccountKitActivity.
My simple login activity, made of two buttons:
public class LoginActivity extends Activity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Button buttonSMS = (Button) findViewById(R.id.buttonSignInSms);
Button buttonEmail = (Button) findViewById(R.id.buttonSignInEmail);
buttonSMS.setOnClickListener(this);
buttonEmail.setOnClickListener(this);
}
public static int APP_REQUEST_CODE = 42;
public void onLoginPhone(final View view) {
final Intent intent = new Intent(this, AccountKitActivity.class);
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
new AccountKitConfiguration.AccountKitConfigurationBuilder(
LoginType.PHONE,
AccountKitActivity.ResponseType.CODE); // or .ResponseType.TOKEN
// ... perform additional configuration ...
intent.putExtra(
AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
configurationBuilder.build());
startActivityForResult(intent, APP_REQUEST_CODE);
}
public void onLoginEmail(final View view) {
final Intent intent = new Intent(this, AccountKitActivity.class);
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
new AccountKitConfiguration.AccountKitConfigurationBuilder(
LoginType.EMAIL,
AccountKitActivity.ResponseType.CODE); // or .ResponseType.TOKEN
// ... perform additional configuration ...
intent.putExtra(
AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
configurationBuilder.build());
startActivityForResult(intent, APP_REQUEST_CODE);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.buttonSignInSms : {
onLoginPhone(v);
break;
}
case R.id.buttonSignInEmail : {
onLoginEmail(v);
break;
}
}
}
}
Anyone as an idea?
I ran in to this exact same problem today integrating Account Kit. Their documentation isn't explicit on this, but you need to add the AppLoginTheme to your themes.xml:
Another possible solution is to remove the theme override for the AccountKitActivity in the manifest like so:
don't do hacks! Just download the latest Facebook SDK, unzip the file and find in the folder facebook-android-sdk-4.20.0\AccountKit the file account-kit-sdk-4.20.0.aar. Change the extension of the .aar file to zip and unzip this accout-kit-sdk file. Go the the folder res\values and copy the values.xml file to your project res/values directory. Voila!
I had this problem. Zac's solution helped me to solve the problem. Below is my solution and this may be helpful for somebody else.
AndroidManifest.xml
style.xml