Gabriel Morin Gabriel Morin - 19 days ago 13
Android Question

Can't use Facebook Account Kit: Error inflating class com.facebook.accountkit.ui.ConstrainedLinearLayout

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?

Zac Zac
Answer

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:

<style name="AppLoginTheme" parent="Theme.AccountKit" />

Another possible solution is to remove the theme override for the AccountKitActivity in the manifest like so:

...
<activity android:name="com.facebook.accountkit.ui.AccountKitActivity" />
...