我正在尝试集成facebook accountkit,以允许用户注册他们的电子邮件或电话号码。但当启动accountkitactivity时,应用程序崩溃,因为它无法膨胀“受限布局”。
错误消息:

java.lang.RuntimeException: Unable to start activity
android.view.InflateException: Binary XML file line #45:
Error inflating class com.facebook.accountkit.ui.ConstrainedLinearLayout

及以下:
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}

我在毕业典礼上用的是:
compile 'com.facebook.android:facebook-android-sdk:4.11.0'
compile 'com.facebook.android:account-kit-sdk:4.11.0'

在尝试启动AccountKitActivity之前,我正在调用accountKit.initialize()。
我的简单登录活动,由两个按钮组成:
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;
            }
        }
    }
}

有人想知道吗?

最佳答案

我今天遇到了一个完全相同的问题,就是集成帐户工具包。他们的文档对此没有明确说明,但您需要将applogintheme添加到themes.xml中:

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

另一个可能的解决方案是删除清单中AccountKitActivity的主题覆盖,如下所示:
...
<activity android:name="com.facebook.accountkit.ui.AccountKitActivity" />
...

08-05 09:36